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 [...]
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
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
Learn to Stop Worrying and Love the Singleton
January 15th, 2010 by Fredrik Olsson — Android, Architecture, Embedded, Java, Tips & Tricks
Enterprise applications and mobile applications have quite different requirements. Starting an enterprise application is just something you do once before it continue running for months or years. On the other side of the spectrum most mobile applications seldom runs for more than minutes, run by a bored users standing in line or riding the bus. [...]
Tags: design patterns, java me, mobile, mock, performance, spring ldap
Queued Background Tasks for Cocoa
May 9th, 2009 by Fredrik Olsson — Architecture, Java
The megahertz race is over, and instead we get more execution cores. This means that we as developers must make our applications parallel, in order to take advantage of the new performance. The easiest way to be parallel is to execute tasks in new threads, something that is useful also for lengthy but not resource [...]
Tags: concurrency, design patterns, frameworks, iphone, mac, mobile, network, objective-c, open source, performance, programming
Bridging the Gap Between Java and Cocoa
March 24th, 2009 by Fredrik Olsson — Architecture, Embedded, Java, Tips & Tricks
Many Java developers are looking at new dynamic languages, such as Groovy and JRuby, mostly because of the freedom and rapid development that a dynamic language allows. Some of my colleagues are also looking at Cocoa and feel daunted at the sight of Objective-C. Here I will use a small example that is easy and [...]
Tags: design patterns, frameworks, iphone, mobile, objective-c, programming, ruby
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
UIButton troubles, a better solution
December 17th, 2008 by Fredrik Olsson — Architecture, Embedded, Java, Tips & Tricks
I described in my previous post how you can change the class of a live object instance. The use-case was a workaround for bug in Cocoa Touch’s UIKit. What if I could fix the bug, instead of applying a work around in my sub-class? Update: Buttons created with UIButtonTypeRoundedRect is a special case returning a [...]
Tags: design patterns, frameworks, iphone, objective-c, programming
