Last week I did a talk at iOSDevCamp DC, an annual event hosted by Luis de la Rosa. I talked about UIStackView, under the admittedly grandiose title of "Mastering UIStackView". I've used stack views for a number of things recently, as I've come to realize they're a lot more useful than a lot of introductory material might suggest. I'll be writing about some of this in the very near future, but in the meantime the excellent Natasha the Robot has already done two blog posts based on stuff that I covered: The Easy Button: A Fancy Animation with StackView Magical View Rotation with StackView Sometimes when I do a technical talk I wonder if people really took anything away from it. Other times, someone does two great blog posts based on the…read more →
Category Archives: iOS
I wrote a post a few months ago about sharing data between iOS apps and app extensions in which I recommended using
NSFilePresenter. But I had to update the post to remove that portion when some helpful people pointed me to Apple Tech Note 2408, which read in part:
When you create a shared container for use by an app extension and its containing app in iOS 8, you are obliged to write to that container in a coordinated manner to avoid data corruption. However, you must not use file coordination APIs directly for this.
That basically meant that it was specifically unsafe to use these classes for what would seem to be one of their primary use cases. That sucked.
However last week the tech note was updated, and the above section now reads:
When you create a shared container for use by an app extension and its containing app in iOS 8.0 or later, you are obliged to write to that container in a coordinated manner to avoid data corruption. However, you must not use file coordination APIs directly for this in iOS 8.1.x and earlier. [emphasis mine]
That's great! In iOS 8.2 or higher, the obvious approach should now be safe. I've updated the original post to restore (and somewhat expand) the original discussion of file coordination.permalink
Over the past month or so I've been diving into Swift, after many years of working with Objective-C on Macs and iOS. It's been a change but, gradually, I'm learning the Swift way of doing things. On the way I've run into a few bumps in the road when dealing with Core Data, and I thought would be useful to share how I got past them. Xcode Generated Subclasses Considered Harmful This is the main impetus for this post. Most other stuff I would expect people to work around eventually, but this one is kind of big. Xcode's generated NSManagedObject subclasses are limited but useful in their own way. If you don't need much, they'll do. Everyone else would use mogenerator. That's if you're using Objective-C, though. With Swift there's a decent…read more →
Since iOS app extensions run as part of a host application rather than as part of their containing app (i.e. your app's extensions run in somebody else's app), data sharing isn't automatic. Finding standard locations like the documents directory doesn't work for shared data. In this post I'll go through the details of how to make it all work. Along the way I'll get into how to set up real-time messaging between apps and their extensions. Not Cocoa notifications, but a variation of file-based IPC that includes a notification system. Most of this is not actually specific to iOS extensions, though it's probably more useful with extensions than in other situations. Code snippets are included, and see GitHub for the full project. Sharing…read more →
iOSDevCamp Colorado was a couple of weeks ago and I did a presentation/demo on iOS app extensions. I wanted to focus on how to actually do things, so mostly I worked in Xcode rather than present from slides. But rather than paste code in as I went or (gasp!) try to do it live, I worked from a git repository I had built while developing the demo app. Every time I made a significant change, I'd commit it. During the presentation I would show some of what I was doing at each step and then jump ahead to the next commit to show the completed version. I like the idea but I need to work on doing it smoothly. One nice thing about it is that I can share the project and have it provide more information on the development process. Rather than just…read more →