Apple’s Swift language, which is not even a year old, has grown on me in ways I would never have expected. Partly, that’s because it has opened my eyes to ways of programming I was unaware of.
One of the programming paradigms that Swift forced me to at least look at was functional programming. What’s functional programming? Well, here’s a post by Guanshan Liu, Functional Programming in Swift, that does a much better job than I could ever do. And there’s a great book, Functional Programming in Swift. Simply put, functional programming allows functions to be used as parameters within a function call. Is that very useful or just another egg-head, ivory-tower CompSci methodology that no app developer really needs? Hardly.
Let’s say within a HomeKit app I’m creating that I have an array of accessories (home-automation devices) and their services. Now, that and a nickel won’t get me a cup of coffee nor do much for any user of my HomeKit app. So I want to use the list of the services’ serviceType, mind you in the same order as Apple’s service types supported by HomeKit’s Accessory profile, and the devices that have those service types. Hmmm… More…
There may come a day, a sad day, when you install the latest version of Xcode, plug-in you iOS device, wait for it to appear in the list of scheme supported devices, and…nothing. Then you click on the scheme pull-down menu and see the following,
How did your iOS device become ineligible for development? Well, I don’t know and nobody else seems to have an answer. But there is a work-around More…
Some migrating their iOS projects over to Xcode 5 but not converting their project’s xib(s) or storyboard(s) might notice that the performance of Xcode drops when trying to edit those files. Looking in Activity Viewer, it isn’t Xcode that is taking-up all the cycles, but a tool, Interface Builder Cocoa Touch, that has now gone from using its normal smidgen percentage of CPU to over 60%! This will make editing a storyboard or xib very painful.
A search of “Interface Builder Cocoa Touch” will not result in links that address this is issue. After all, Xcode 5 has only been publicly available since today. So what to do?
The problem is the Interface Builder Document settings for the iPhone Storyboard or xib in which the performance is laggy.
Start by looking in the File Inspector of each storyboard in which the performance problem exists. It is likely that the storyboard Interface Builder Document setting was set for “Xcode 4.6”. That is, as it turns-out, bad. Changing the IB Default Document setting of the xib or storyboard to “Default Xcode 5” will fix the problem. Once you make that change, the Interface Builder Cocoa Touch tool will return to its sipping of only a few threads and using 0.0% of the CPU.
Since I haven’t seen this on Stackoverflow, the following is a method to transform a vector (GLKVector3) based on an attitude quaternion (GLKQuaternion).
First, assume that you have a GLKVector3 as input, call it inputVector3. inputVector3 could be yaw, pitch, and roll influences from an aircraft’s control surfaces or thruster output on a spacecraft. You know your vehicle’s attitude and have calculated that attitude into a quaternion. So, the goal is to have the inputVector3 transformed into an ivar, say GLKVector3 deltaV, that is in terms of the vehicle’s attitude.
- (GLKVector3)transformVector3:(GLKVector3)inputVector3 withAttitudeQuaternion:(GLKQuaternion)attitudeQuaternion
GLKVector3 deltaV = inputVector3;
//Always ensure that your attitude quaternion has been normalized
attitudeQuaternion = GLKQuaternionNormalize(attitudeQuaternion);
//Convert the normalized attitude quaternion into a GLKMatrix3.
GLKMatrix3 tempQMatrix3 = GLKMatrix3MakeWithQuaternion(attitudeQuaternion);
//Since v' = v T, where T is a transform matrix, multiply
//the attitudeQuaternion GLKMatrix3 with the necessary GLKVector3.
deltaV = GLKMatrix3MultiplyVector3(tempQM3, deltaV);