Tag Archives: iphone dev

Encode what cannot be NSCoded

Isn’t it annoying that UIImage can’t be serialized (as evident with the error “UIImage unrecognized encodeWithCoder”).  Really throws a spanner in the works when trying to serialise your UI (or applying this hack) given that images are everywhere… Well this can easily be fixed with a monkey-patch, and a pretty safe one at that. Here   …Continue Reading

Copy what cannot be NSCopied

Sometimes you need to deep-copy an object in Objective-C.  Normally you just go newObject = [oldObject copy].  But what if oldObject does not support NSCopying (typified by the error “copyWithZone: unrecognized selector”)? Well.. if your object supports NSCoding, then you can simply serialize it, and deserialize it!  Saves you having to monkey-patch the copyWithZone method   …Continue Reading

iPhone dev – forcing the user language

From my post on StackOverflow You can force the language like so: [[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@”en”, nil] forKey:@”AppleLanguages”]; And undo this setting by: [[NSUserDefaults standardUserDefaults] removeObjectForKey:@”AppleLanguages”]; Consider if you need to call [[NSUserDefaults standardUserDefaults] synchronize]; This change is persistant and only needs to be set once. NB. you will normally have to restart the app   …Continue Reading

Slide to reload

I love Tweetie2’s slide to reload feature. Maybe one day I will use a similar device, fortunately Dr. Touch has an example.

iPhone Mutex/Sempahore

Looking for Mutex and Semaphore in the iPhone SDK?  The classes you want are NSLock and NSConditionLock.  You can use NSConditionLock just like a semaphore. Here’s a good NSConditionLock example For Mutex’s, use @synchronized(self), or another NSLock object.

How to make pull to reload tableview like Tweetie 2

I really like this feature in Tweetie 2, very innovative. Well if you ever need to do something similar, you can. Here’s how

Like This App? Rate it…

MobileOrchard has some great ideas regarding fighting the negative App-Store bias (caused by the ‘rate on delete’ feature). I tweaked their code a little, localising it, and making it ask a second time if the user clicks ‘No Thanks’ the first time (in case they were simply busy). My advice would be to make sure   …Continue Reading

dSYM Archive Script

Archiving dSYM for production builds is a good idea. An easy way to do it is to add a build script at the end of your build. in XCode->Targets->YourBuildName right click, and select Add -> New Build Phase -> New Run Script Build Phase and copy in this script. ArchiveDSYMScript Repeat for all targets. Ensure   …Continue Reading

Analysing iPhone Crash Dumps (OS 3.0)

If you are sent a crash dump by the Approval Team, download it through iTunes Connect or some other way you need to be able to interpret them into something usable. Here’s how: Run /Developer//Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash xxxx_2009-11-12-140756_iPhone.crash > crash_with_symbols.txt This is the difference in knowing the exact line of code that crashed, and knowing it crashed.   …Continue Reading

MKDotBounceAnimation animationDidStop bug

MKMapViews seem buggy when created problematically. Some tips: set the delegate to nil when the delegate dealloc’s, as per that advice to fix one of the crashbugs Either make the instance it static so you never release it, or schedule a delayed ‘release’ command to avoid theanimationDidStop crashbug. What I do to avoid theanimationDidStop crash is instead of   …Continue Reading