I previously wrote a blog post titled Performing any Selector on the Main Thread detailing a convenience category on NSInvoication for easily creating invocation objects that could be invoked on any thread. This category has served me well, and even got traction in the iOS developer community, so I never bothered to stop and think [...]
Entries Tagged 'Cocoa' ↓
Invoke any Method on any Thread
August 8th, 2011 by Fredrik Olsson — Architecture, Cocoa, Dynamic languages, Tips & Tricks
Tags: concurrency, design patterns, iphone, mac, objective-c, open source, programming, tips, tutorial
Auto-incrementing Build Numbers in Xcode
May 31st, 2011 by Fredrik Olsson — Cocoa, Testing, Tips & Tricks
Users and testers will find bugs you are sure you have already fixed. Sometimes they use the wrong version, sometimes your fix is not as good as you thought. Either way a tiny unique version number visible in the app can save you hours of work. Incrementing the version number of your project for every [...]
Tags: iphone, objective-c, scripting, tools, tutorial
The state of iOS Open Source – and what to do about it!
May 16th, 2011 by Fredrik Olsson — Architecture, Cocoa, Tips & Tricks
There is a vibrant community of open source projects for iOS. You need a calendar UI components or a JSON parser? No problem, the projects are out there. Most code out there is of very high quality. Unfortunately the distribution of the code is generally very crude, barely half a step away from sharing code [...]
Tags: frameworks, iphone, maven, mobile, objective-c, open source
Sync-Async Pair Pattern – Easy concurrency on iOS
April 28th, 2011 by Fredrik Olsson — Architecture, Cocoa, Testing, Tips & Tricks
Apple provides many tools for implementing concurrency in your application. NSOperationQueue, GCD, or simply using performSelectorInBackground:withObject: that is available on each and every object, are just some examples. The tools are there, yet implementing good concurrency is hard. The solution I have found is not yet another tool, or framework, but a simple pattern. I [...]
Tags: automated testing, concurrency, design patterns, iphone, objective-c, programming
Exceptions and Errors on iOS
October 13th, 2010 by Fredrik Olsson — Architecture, Cocoa, Embedded, Testing, Tips & Tricks
Cocoa, and by inheritance Cocoa Touch on iOS makes a clear distinction between what is an exception, and what is an error in your application. This should be obvious since NSException and NSError both inherit from the NSObject root class with no relations at all. Programmer vs. User Exceptions are intended for signaling programming errors [...]
Tags: design patterns, iphone, objective-c, programming, tutorial
Future Cocoa Operation
August 19th, 2010 by Fredrik Olsson — Architecture, Cocoa, Tips & Tricks
In Java you have for quite some time had the Future interface for encapsulating an asynchronous calculation. Cocoa has had the abstract NSOperation class to encapsulate asynchronous operations. NSOperation do not have any facilities for returning a result when done as the Future do, you are left to implement this on your own. Which I [...]
Tags: concurrency, design patterns, iphone, Java, mobile, network, objective-c, programming
Rewriting a Public Cocoa Touch API
May 25th, 2010 by Fredrik Olsson — Architecture, Cocoa, Embedded, Tips & Tricks
Cocoa Touch added API for presenting a view controller in a popup bubble in iPhone OS 3.2, the responsible class is named UIPopoverController. One would guess that this new class is a subclass of UIViewController, just like UINavigationController is, but that is not the case. One would also guess that in functionality many ideas for [...]
Tags: api, apple, cocoa touch, frameworks, ipad, iphone, objective-c
Performing any Selector on the Main Thread
March 30th, 2010 by Fredrik Olsson — Cocoa, Embedded, Tips & Tricks
Many UI frameworks, including AppKit for Mac OS X and UIKit for iPhone OS, require that all methods to UI components are sent on the main UI thread. Cocoa and Cocoa Touch make this quite easy by providing for example -[NSObject performSelectorOnMainThread:withObject:waitUntilDone:] in Foundation. Making updating the text for a text field a snap: [someTextField [...]
Tags: cocoa touch, concurrency, iphone, mac, mobile, objective-c, open source, programming, tips, tutorial
iPad, the Future, and the Luxury of Starting Over
January 28th, 2010 by Fredrik Olsson — Cocoa, Events
A luxury that you seldom have in the world of software development is the luxury of starting over. I am not talking about throwing away everything and start from scratch. But just taking what you have, and all the experiences learned. Apply some major refactoring to make what works really shine, and without care of [...]
Tags: apple, cocoa touch, frameworks, innovation, ipad, iphone
Google Translate and iPhone apps
January 11th, 2010 by Fredrik Olsson — Cocoa, Embedded, Tips & Tricks
The Cocoa and Cocoa Touch frameworks has a really nice function for acquiring a localized string NSLocalizedString(). Just pass in a key and you are done, for strings that are known at least. Sometimes you are getting unknown strings from a data source not under your control, strings representing just a fraction of the text [...]
Tags: frameworks, iphone, localization, mobile, objective-c, web
Add some polish to iPhone app start up
June 29th, 2009 by Fredrik Olsson — Cocoa, Embedded
First impressions last, and the very first impression your users have of your iPhone application is the start up. First step is to have a nice Default.png, but not many words spilled on that one, it is well covered in Apple’s documentation. Creating a perfect Default.png is impossible, especially if you have different setup of [...]
Tags: frameworks, iphone, mobile, objective-c, programming
Regular Expressions and Cocoa
May 6th, 2009 by Fredrik Olsson — Cocoa, Embedded, Tips & Tricks
Regular expressions is a powerful tool for solving many problems related to text. It can be misused as any good tool, but there are moments when they are the best solution for a given problem. At those moments the lack of regular expressions for Cocoa on Mac OS X and Cocoa Touch on iPhone OS [...]
Tags: apple, frameworks, iphone, mac, mobile, objective-c, open source, performance, programming, regex
Introduction to iPhone development
May 1st, 2009 by Christian Hedin — Cocoa
It has been little more than 2 years since the iPhone was first announced and during that time it has managed to make a huge impact on the mobileindustry. Introduction Just recently, iPhone sales figures surpassed all windows mobile phones combined and in several markets the iPhone has been a top selling phone model. Together [...]
Tags: iphone, jayview, programming
Adding Sorted Inserts to Cocoa Arrays
March 28th, 2009 by Fredrik Olsson — Architecture, Cocoa, Embedded, Tips & Tricks
NSArray and NSMutableArray have methods for sorting arrays, NSArray returns new sorted arrays and NSMutableArray can be sorted in place. The sort methods comes in three flavours; using a function, using a selector, or using an array of NSSortDescriptor objects. NSArray admits to sorts being a slow operation, and adds a method pair for comultive [...]
Tags: frameworks, iphone, mobile, objective-c, open source, performance, programming
UIToolbars in iPhone OS 2.x
March 22nd, 2009 by Fredrik Olsson — Cocoa, Embedded, Tips & Tricks
The new release of iPhone OS 3.0 adds some nice API:s for managing a contextual toolbar. This is well needed as toolbars in the current iteration of iPhone OS is not only poorly documented, it is also quite hard to do right. So I will go over how to do toolbars the right way, for [...]
Tags: apple, design patterns, frameworks, iphone, mobile, objective-c, open source, programming, tutorial
