So far there is no actual hardware available with HomeKit support. However this is about to change quickly.
Just this week a number of products with support for HomeKit have been announced already. These include:
It’s likely more announcements will be published because of the ongoing CES conference in Las Vegas. (I’ll make sure to keep the above list up to date).
Personally I’m still eagerly awaiting Philips Hue to adopt HomeKit.
Can’t wait for official hardware support for HomeKit? There are several efforts to bring HomeKit to any (programmable) hardware. These projects implement a HomeKit accessory bridge by reverse engineering the HomeKit accessory protocol that works over Wifi and Bluetooth LE. Use at your own risk.
New in AppleScript is the ability to report progress. This enables the Finder or other UI in Yosemity to show progress indicators while your script is running.
1 2 3 4 5 6 7 8 |
|
Script editor will run this script and show it’s progress at the same time:
Reporting progress in AppleScript looks very similar in usage to the NSProgress class introduced in iOS 7 and OS X 10.9.
The NSProgress class provides a self-contained mechanism for progress reporting. It makes it easy for code that does work to report the progress of that work, and for user interface code to observe that progress for presentation to the user.
Not only does NSProgress
provide a way to transparently handle progress within the same process, it also works between processes. I’ve used this before in a simple command line utility to report it’s progress to any UI wrapped around it.
A small demo app I wrote proves AppleScript is using NSProgress
as well, making it very easy to observe AppleScript progress in your own software. Even when that script is executed outside of your sandbox using NSUserScriptTask
.
It doesn’t require a lot of additional code to get this working:
1 2 3 4 5 6 7 8 9 |
|
It’s good to see NSProgress
being adopted in different parts of the OS. However because the class is still relatively unknown it is not always clear where it’s functionality is available.
On his weblog Charles writes about the Making of Findings. The original mockups are dated 5 years ago already and it’s interesting to see how the interface evolved over the years.
]]>I ran into this when trying to build lxml for Python recently. This failed with the following error message:
clang: error: unknown argument: '-mno-fused-madd'
Google or stackoverflow provided no answer to this problem.
As long as the build configurations are not updated an up-to-date OS X system will currently fail to build modules like lxml for Python.
Luckily a (temporary) solution is available in the the Xcode release notes:
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors.
[..]
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning.
Use the following to successfully build lxml on Mavericks with LLVM/Xcode 5.1:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install lxml
]]>An example:
1 2 3 4 5 |
|
My builder categories on NSDate and NSURL are available on github for review. Let me know what you think.
Originating from Java the builder pattern is used to create new objects using a dedicated ‘builder’ object, instead of having every parameter in the constructor.
This pattern actually also currently exists in Objective-C Foundation. NSDate
has NSDateComponents
and as I recently wrote iOS 7 / Mavericks added NSURLComponents to complement NSURL
. Both dates and URLs are immutable objects in Foundation with only simple initializers. To have more control over their creation you use their builder objects.
Klaas Pieter actually expands on the builder pattern and shows a very elegant way of using builders in Objective-C initializers using blocks. Illustrated using his pizza example:
1 2 3 4 5 |
|
turns into
1 2 3 4 5 |
|
Perfect for application on the existing builder objects in Foundation in my opinion.
]]>Receiver (<JBWMasterViewController: 0x8cbd540>) has no segue with identifier 'showDetial'
You have probably seen a similar crash yourself, caused by a call to -[UIViewController performSegueWithIdentifier:sender:]
with an unknown identifier. To prevent having hard-coded strings repeated all over the place I was already using constants to refer to my identifiers. However maintaining these constants manually is still prone to errors such as small typo’s. As demonstrated by my crash mentioned above.
To finally rule out crashes like this from now on my projects use a small python script to generate NSString
constants for all identifiers found in UIStoryboard
files.
An example project is available on github that shows the script in action. The projects storyboard has two controllers and a single segue connecting them. Both controllers and the segue have an identifier set in the inspector.
This results in the following constants being generated:
1 2 3 4 5 6 |
|
The identifier prefix is customizable of course. Import the header file when needed and you’re good to go. Each time you modify a storyboard file your identifier constants will be generated automatically, providing you with:
To make this work the python script is setup as a Run script build phase for the main project target.
The python file itself is stored in a Scripts
directory. The generated files are placed in a generated
directory next to the regular source files. I also commit the generated files to git.
Paths for the storyboard files and generated code are specified as input and output files for the build phase. This enables Xcode to figure out dependencies and will run the script only when the storyboard files have actually changed.
For a regular project generated from an Xcode template my projects use the following directory layout.
Project/
Scripts/
- generate_constants.py
TargetName/
generated/
[header / implementation]
Base.lproj/
Main.storyboard
Main_iPad.storyboard
The script will work with different directory layouts, just make sure you modify the paths used in the build phase.
]]>iPad2,1
or MacBookPro10,2
and indicate what device variant and generation the software was used on.
The raw identifier is not something you usually display in a user interface directly, instead you show a more friendlier name. Unfortunately a way to translate iPad2,1
to iPad 2 (Wifi)
is not readily available.
For that reason I created my own collection of iOS and Mac device model identifiers.
The collection is available as a plist file where each identifier is mapped to three values:
For the most up to date version download the raw model-identifier.plist file from master.
Note: An older identifier may refer to multiple models from different years or with different characteristics. In this case the Generation
or Variant
key is not unique and is usually left out. Somewhere around 2010 this practise changed and each identifier is unique for a specific device generation and variant.
To include the model identifier in your own statistics or client user-agent you can find it using the command line:
$ sysctl -n hw.model
Or to get a device model identifier using code, on Mac OS X or iOS use:
NSURLSession
& family) iOS 7 and Mavericks also bring a new way of constructing URLs. Similar to what NSDateComponents
provides for a NSDate
we can now use NSURLComponents
to inspect, build and modify NSURLs
.
An example:
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"http";
components.host = @"joris.kluivers.nl";
components.path = @"/blog/2013/10/17/nsurlcomponents/";
NSURL *url = [components URL];
// url now equals:
// http://joris.kluivers.nl/blog/2013/10/17/nsurlcomponents/
A NSURL object is only returned if the combination of set properties on NSURLComponents result in a valid URL, nil
will be returned otherwise.
Use initWithURL:resolveAgainstBaseURL:
or initWithString:
to create a components object with an initial set of values.
I would have linked above API to the official documentation, unfortunately like with many other recently introduced functionality nothing is available online yet. The only reference to NSURLComponents
is it’s public definition in NSURL.h
in the relevant SDKs. So I’ve published the relevant NSURLComponents declaration as a gist for easy online access.
Out of all the newly introduced API’s on both Mac and iOS this class will probably be the one I use most.
Any feedback is welcome. I’m @kluivers on twitter.
For more posts about new iOS 7 & Mavericks additions see also:
]]>The developer kit contains 3 soft rubber shell devices, each in a different color. The bottom side has some kind of adhesive material applied so the beacon can be attached to a flat surface. There’s no on/off button. The device is broadcasting all the time, even before getting out of its packaging. On a single battery (included) it should be able to survive up to two years.
Not imporatant but worth a mention: for a developer kit the packaging is quite nice and well designed.
A dev preview kit is available from estimote.com
On the inside the beacon contains a 32-bit ARM Cortex M0 CPU. This is the brain that coordinates between the onboard sensors and operates the Bluetooth LE profile.
Using a Bluetooth LE scanner like LightBlue or BLExplr you’ll be able to find each device. The apps will discover several LE services, presumably used to access its sensor data (accellerometer) or to flash the firmware over the air.
In addition to the published Bluetooth LE services each device conforms to the iBeacon specification. An iBeacon publishes certain information in its advertising packet that makes it possible to tie in to the new CoreLocation functionality in iOS 7. Because all information is contained in the advertising packet it’s not needed to actually connect to the device in your software. If you are mainly interested in iBeacon you can ignore the services published by the device.
iBeacon is part of the CoreLocation framework in iOS. Using a beacon is similar to geofencing. But instead of using a gps coordinate you are basing your proximity on receiving a Bluetooth LE signal. This makes it possible to detect proximity of moving targets by placing a beacon on them, instead of having to rely on a fixed gps location.
Each beacon has three identifiers:
proximityUUID
: a unique UUID to distinguish your beacons from those others are using.major
: used to group related sets of beaconsminor
: used to identify a beacon within a groupThe major and minor numbers are basically arbitrary numbers and your app will have to give those a meaning using tie-ins to your product or shop database for example.
Currently on the Estimote the identifiers are specified by the manufacturer. However I have been promised functionality to customize these properties using an upcoming version of the Estimote app.
Developers take note, if you want to scan for your Estimote beacons use the following UUID. It’s currently not available in any of the documentation.
The UUID for an estimote beacon is:
B9407F30-F5F8-466E-AFF9-25556B57FE6D
One wish I have is to also be able to customize this UUID in the future.
First you set up a beacon region to scan for.
1 2 3 4 5 6 7 8 |
|
As soon as you enter a region you’ll receive a notification via the CLLocationManagerDelegate mechanism. Next thing you can do is start monitoring for individual beacons in that range.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
You can also use the AirLocate WWDC sample code published by Apple to scan for the devices. Just make sure you update the UUID with the one provided above.
Technically proximity detection of Bluetooth LE devices is perfectly possible without iBeacon. You can find the signal strength by just scanning for any advertising packet using the CoreBluetooth framework. I already demonstrated this in my UIKonf talk last april, when iBeacon was not even announced yet.
So why would you want to use iBeacon instead of making your own proximity detection on top of CoreBluetooth? The iBeacon functionality offers certain advantages:
Let me know your opinion on iBeacon or what you would use it for. I’m @kluivers on twitter.
]]>However the number of projects I started and never finished is growing. Sometimes I get bored with a project or even forget about it and just start something new. Inspired by Matt Swanson I decided to publish the list of my current projects.
Focus is a matter of deciding what things you’re not going to do.
- John Carmack
By keeping track of my projects here I hope to shorten the list eventually. Preferably by launching a finished version to the public, or to cancel the project all together. This also means I’ll try not to start new projects anymore and instead focus on any of the existing projects.
What started as a weekend project to render vectors from custom shape files eventually turned into a Mac application to generate PNG artwork for apps and web. The general mechanics of the app are finished and I use the app regularly myself. But too many details required for a release version are still missing. Teaser Website
My Quartz Composer implementation for iOS. An ongoing effort to implement more Quartz Composer functionality & patches. github.com / qc-mobile
I’ve been playing with the thought of releasing a game for iOS. I’ve got several ideas ranging from very simple to kind of complex. The idea is to release the most simple game first to gain some experience using the frameworks involved and build on that experience to create the complex game. Especially now that iOS 7 will introduce SpriteKit for 2d games this idea got more enticing.
Floorplans is a codename for my app to procedurally generate models for 3d buildings. It uses SceneKit on the mac to display models and content.
So many new frameworks and technologies will be introduced with iOS 7 & Mavericks. Unfortunately due to the NDA developers are not able to post any in depth information yet. I’m working on a series of articles detailing my experiences with some of the new frameworks. More on that as soon as iOS 7 goes live.
Posts about new things in iOS 7 published so far:
]]>Liquid error: undefined method `[]’ for nil:NilClass
An earlier post I published lists the source code for the demos in the talk.
I also maintain a list of gadgets using Buetooth Smart in case you are looking for some hardware to play with.
]]>.qtz
on your iPhone or iPad. Similar to what the Quartz Composer framework provides on OS X.
Let me make one thing clear, I don’t see QC as a tool to create iOS applications. After some recent Facebook Home & Quartz Composer more people have taken an interest in QC for prototyping. I’ve also seen questions on how to convert these prototypes into code. This project is not an answer to that question. Prototypes in QC are just that, prototypes. Use UIKit to implement the actual app.
However I see some possible integration for QC and UIKit, like how it’s currently possible to integrate QC and Cocoa on the Mac. QC is ideal to create:
all without writing much code.
But first of all this is a side project for me to challenge myself to learn new things.
Currently only a small subset of the available patches has been implemented. This is enough to show something interesting on screen but your random composition will probably fail to render. I’m currently working to add support for more patches.
For demo purposes I implemented all patches needed to render the iMessage recreation by Jay Thrash (based on a concept by Florian Peninon).
See the following video for a demo:
Liquid error: undefined method `[]’ for nil:NilClass
As already mentioned a lot of patches are still missing. This is an ongoing effort as I create more demo compositions and try to make those work.
The video also shows performance is far from optimal. Currently overall architecture and implementation is kept as naive and simple as possible. A first improvement I have planned is a rewrite of the image and texture handling, something that is currently incorrect and also the main performance hog.
For the source code see qc-mobile at Github. The project also contains the demo application shown in the above video.
Do you have a composition you would like to see work on iOS, or got any comments? Any feedback is appreciated.
]]>A quick search (goog, duck) returns a set of animation curves implemented by Jeff LaMarche. However as I found out some of those functions are incorrect. The comments for that post provide a few corrections, but not for all functions.
For this reason I implemented my own set of interpolation functions.
I decided to implement Quadratic, Cubic, Exponential and Sinusoidal easing functions. This is the same set also provided by certain Quartz Composer patches. See the interactive graph for more details on each of the individual curves.
Each of the functions returns the interpolation between start
and end
for the given input time
(where time is between 0.0 to 1.0).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
The code is available from the jk-interpolation git repo over at bitbucket.
This repository also contains one Xcode project used to generate the data for the above graph.
]]>When trying this out for the first time in one of my projects it immediately warned me about a potential bug, where I forgot to call super.
Add the attribute annotation to the method declaration in your interfaces.
1 2 3 |
|
When overwriting your important method in a subclass you will now be warned in case you forget to call super.
1 2 3 4 5 6 7 8 9 |
|
Next time you compile you’ll be presented with the following:
This has been confirmed to be available as of Xcode 4.6.1
]]>The video of my talk on Bluetooth Smart in iOS and Mac apps will be posted online soon. However because the demos in my talk are not easily reproduced from video I published the code for the projects online.
The conference day was followed by UIKode, a day long hackathon at the Readmill offices. I was glad to see my talk inspired a few teams which resulted in a nice amount of Quartz Composer and Bluetooth Smart usage. My favourite project presented at the end of the day was a Bluetooth Smart based remote control for your iPhone camera.
For me the day almost resulted in failure when reverse engineering the peripheral services used in the Bluetooth Bulb turned out to be a bit harder than expected. (More on those efforts in a future post).
So eventually I gave up and decided to hack a slit-scan like video effect in Quartz Composer (thanks Niels van Hoorn & team for the idea).
Download Composition (.zip, 5.1mb)
]]>While relatively unknown, Quartz Composer (QC) is a versatile tool that is quite big in certain niche scenes. One of which is the VJ world. And recently I was reminded again that QC is an awesome tool for UI prototyping too.
For example Mike Matas (of Apple, Push Pop, Nest and Facebook fame) is known to use the tool a lot while designing his stunning interfaces. Facebook Home was prototyped and designed using QC, after he introduced the workflow there.
It’s no secret that many of us on the Facebook Design team are avid users of QuartzComposer, a visual prototyping tool that lets you create hi-fidelity demos that look and feel like exactly what you want the end product to be. We’ve given a few talks on QC in the past, and its presence at Facebook (introduced by Mike Matas a few years back) has changed the way we design. - Julie Zhuo @ Medium.com
To get a feel of how to start prototyping using Quartz Composer check the videos posted on Vimeo by Dave O Brien. In 11 videos he shows how you would create a dynamic interface like Facebook Home.
So to possibly direct some attention within Cupertino back to QC I’ve started filing some radars with updates I would like to see:
Let me know what updates you would like to see for QC and what radars you filed. I’m @kluivers on twitter and also @kluivers on App.net.
]]>While I consider myself a power user I was pointed to two for me previously unknown shortcuts in apps I use regularly. Reason enough for a new blog post.
For me it is the most avoided feature in Mail on mobile. Probably because it took way too much effort to remember in what mailbox the draft was stored, or to navigate there in the app.
Turns out there is a simple shortcut to reach all saved drafts from anywhere in the app using a simple gesture.
Long press the compose mail button:
This will bring up a new screen that lists all previously saved drafts. Knowing this might actually make me use drafts again.
Update: This gesture also works the same way in the official Twitter app, and in Tweetbot/Netbot.
A regular checkin is a multi step process:
The last screen can become an annoyance, especially if you never use comments or social actions (like me). Luckily someone at Foursquare felt the same way. All these steps can now be skipped using a single gesture.
Long press any venue name, and wait till the timer animation (pictured below) runs out to check in immediately.
Bonus: Foursquare app is full with little easter eggs. Scroll down (a lot) on the Foursquare main screen for example:
Know any more easter eggs or shortcuts in other apps? Let me know. I’m @kluivers on Twitter or @kluivers on App.net.
]]>PARStore
: a key value store designed to work on top of syncing mechanisms like iCloud and DropBox.
To make syncing as transparent as possible this store’s functionality is kept as limited as possible. It is definitely not a fits all solution but works well in our use-case.
Currently PARStore:
Next to that each device operating on the same store only writes to it’s own database file. Locally it reads in databases from other devices and merges everything into a single timeline.
The store is currently implemented using CoreData. Each device database is added as a NSPersistentStore
to the same NSPersistentStoreCoordinator
. Only the database owned by the local device is added as a read-write store.
Having each device writing to it’s own database file prevents possibly destructive merge-conflicts on that file.
The source code for PARStore is available on github with a liberal BSD license attached. Feedback is appreciated.
]]>The app was created to solve a single problem: stream system audio to multiple AirPlay speakers at the same time. For an app created purely for myself it’s doing surprisingly well.
Here’s an overview of past months downloads:
While not going into the exact number of downloads, it’s certainly an interesting graph to look at. Even with a single month of data there is a pattern of peaks and drops recognizable.
The same data averaged by weekday shows a clearer picture:
On average the number of Airwaves downloads increases during the weekends. This can probably be explained by customers searching for Audio and AirPlay related apps, which happens more often when not at work.
Not sure how to explain the dramatic drop on Thursdays.
(Popularity during the weekend could just as well be a App Store wide trend, however I don’t have other Mac app sales stats to compare to. I also don’t see a similar trend in my iOS apps).
This blog has a pattern completely opposite of the graph above. Guess my readers (you) primarily visit during working hours.
More like this or have a comment? Follow or message @kluivers on Twitter or kluivers on App.Net.
]]>Segues make it easy to abstract view controller transitions into reusable objects. Instead of having all the animation logic in your view controller the segue is now responsible for that. The view controller its role is reduced to configuring the segue and view controllers involved in the transition.
When done right this usually results in cleaner and more reusable code.
The custom image transition segue will animate an image from its current position to a new position in a new controller. To see what this looks like try running the source code or watch it on YouTube.
To use a custom segue, create it in your storyboard like any other segue. Set it’s type to Custom
and it’s class to your custom subclass next. Optionally set an identifier.
The segue takes care of the actual animation in the - perform;
method. Instead of moving the original UIImageView
from one view controller to the other, a temporary UIImageView
is used to fake the effect. This temporary UIImageView
is added to the application window itself to stay on top of all other content. At the same time it will show the destination view controller using an ordinary modal transition, that will occur in sync with and underneath the custom image animation.
The original image is hidden as soon as the transition starts and the destination image is shown as soon as the transition ends. All together this looks like one image smoothly transitioning to another controller.
To keep this as reusable as possible a custom segue shouldn’t need to know anything about it’s source and destination view controllers. Instead the segue can be configured before execution using - prepareForSegue:sender:
in the originating controller.
The image transition uses this place to set three properties:
sourceRect
- The original image rectangledestRect
- The destination image rectangletransitionImage
- The image to animate from sourceRect
to destRect
These properties determine what the animation looks like without the segue having to know where to get that data from.
As of iOS 6 it’s also possible to unwind back to an earlier controller in your navigation path using a segue. Controllers you want to unwind to need an unwind action declared:
1 2 |
|
Next ctrl-drag from your control to exit button and to connect to one of the available actions. You’ll find the exit button as a green icon for each controller in your storyboard.
For the default push and modal segues this will use the same animation but reversed. For a custom segue no automatic reverse is provided so one of the default transitions will be used. It is also not possible to specify a custom class for an unwind segue in your storyboard.
To provide a custom segue for an unwind action you need to implement - segueForUnwindingToViewController:fromViewController:identifier:
in the view controller you are unwinding to. This can be the same custom segue, or a different implementation depending on your needs.
For JKImageTransitionSegue
this is also the place where the segue is provided with the right configuration, similar to prepareForSegue:sender:
. In addition a custom unwinding
property is used to let the segue know it should perform a reverse animation.
I’ve set up a bitbucket repo to show this all in a working example.
Hopefully you’ll find this transition useful for your own app, or for inspiration when building your own transition. Some other interesting open source transitions available online:
For feedback I’m available as @kluivers on twitter.
]]>