All posts filed under: Dev

Reducing Cognitive Load of Code

Dev

I found this post called “How to reduce the cognitive load of your code” through Gus Mueller’s blog, and I wanted to endorse it as well. A good set of guidelines are: don’t be cute, don’t use weird formatting, keep it simple, and really, really, don’t be cute.

Moving From Parse to OneSignal for Push Notifications

Dev

Parse is shutting down, and if you want your app to keep working, you’ll need to move to something else. I’d recommend doing it sooner than later. Thankfully our app isn’t out for another few weeks, and since the only thing we were using Parse for was push notifications, it wasn’t more than a couple hours of work to switch over to something new. The thing we found to handle our push notifications was One […]

Email Validation String Extension

Dev

I’ve been using this extension on on String to make checking if a string is a valid email easy. If you know a better place this could live, let me know, but an extension on String felt as good a place as any. I didn’t write the original regex (although I did need to tweak it to make addresses with + in them work), but I’ve tested it and it works well as far as […]

Less Gross Storyboard Segue to a Navigation Controller

Dev

This is a really ugly piece of code I’ve found myself writing in Swift whenever I’m preparing a storyboard segue where the destinationViewController is a UINavigationController whose root view controller is the thing I actually need to set properties on: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if let viewController = (segue as? UINavigationController)?.topViewController { // Set up the view controller } } And so I decided to make this slightly less terrible by adding […]

Brent Harping on Swift Limitations

Dev

Brent is harping on limitations you hit when trying to use protocol oriented programming in Swift: But these days we’re smarter: we use protocols. There’s no reason Folder and File should descend from the same class — they’re almost entirely different, and inheritance is a pain to deal with, so we use protocols instead. And we’re happy. It works great. Until you realize that, in Swift, you can’t do this. I hit something like this […]

The Growing iOS SDK

Dev

David Smith writes about how much the iOS SDK has grown over time. One thing that was interesting is that more “SDK elements” were added in iOS 8 than iPhone OS 2 (which is crazy). The last paragraph echoes something I’ve felt for a while: There was a time when I felt like I knew my way around pretty much every non-game SDK available on iOS. Now I often find myself stumbling across frameworks that […]

Answers Events by Crashlytics

Dev

I’ve used Crashlytics for beta testing my new app, including their lightweight analytics-thing Answers. It’s cool in that it shows you the most relevant data, but I was never going to be able to sell it as a replacement for Flurry or Google Analytics (which I loathe). Today they announced Answers can do event tracking, and on top of that it looks fabulous. The web UI makes it really easy to see and add the […]

Fix Broken Swipe to Go Back With Hidden Navigation Bar

Dev

Occasionally you need to a show a view controller as part of a UINavigationController stack where you want the navigation bar hidden. Unfortunately, hiding the navigation bar breaks the swipe right to go back feature. You can fix it by doing this in your viewDidLoad method: navigationController?.setNavigationBarHidden(true, animated: true) navigationController?.interactivePopGestureRecognizer.delegate = self

Swift NSManagedObjectContext Extension to Delete All Core Data Objects

Dev

I made this NSManagedObjectContext extension so that I could delete all of a users data when they log out of the app I’m writing. The alternative was to delete the sqlite file itself and reinitialize my Core Data stack, but that seemed potentially more problematic and less safe. The two instance methods on NSManagedObjectContext for deleting objects are: func deleteAllObjects(error: NSErrorPointer) Delete all objects in a context. Bails out and returns an error if there’s […]

Core Data Programming Guide Updated

Dev

I’ve used Core Data in most apps I’ve written since 2009, and I’ve felt for a long time is that the documentation was pretty lacking and out of date in a lot of places. I haven’t read it yet, but Apple has updated the Core Data Programming Guide today to “reflect current best practices and APIs.” I’m hopeful that things are getting a little better, but there’s apparently no reference to Swift, so, who knows.