OmegaDelta.net

Hong Kong

iPhone dev – forcing the user language

2010-03-11 01:39

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 for this to take affect.

I agree there is little need to allow the user to specify a language. However the one exception is being able to override the language and set it to the developer’s native language. If the user can speak the developer’s language (e.g. English for me) then they may wish to use the App in that language, if the translations are incorrect.

I reference this answer: http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language/1670524#1670524 (the answer doesn’t actually work for me, but following the ideas in the comments did. The undo stuff I worked out.

Slide to reload

2010-02-26 18:06

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

2010-02-26 18:05

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

2010-02-26 14:05

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…

2010-02-14 20:52

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 you put the dialog in a place where the user isn’t busy doing this.  For GPS Log I don’t ask this immediately on launch, as most people launch when the need to log a location, and rating an app is the last thing on your mind.  Instead I ask it after the user shares some entries. I figure at this point they’re just at home, or somewhere relaxing. I only show it to people who have bought the software too…

This guy has some tips on getting the review URL.

Basically it boilds down to this:

http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=30000000&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8

Where 30000000 is your App ID.

I have no idea what ‘Purple+Software’ is, but trying to replace it didn’t seem to help… so I just left it in.

Kidney Watch 2.0

2009-12-22 14:25

After some talking with Mr Spiff in Feb this year, and copping some harsh criticism on the last method, it became apparent that work was needed.

Firstly – accuracy. It is hard to get your address in places like Asia and Latin America (generally the places where you need it the most). Chinese addresses are über-long, but at least they have them. In Peru? Forget about it! Even the taxi drivers can’t find addresses that are printed on Peruvian business cards.

GPS fixes this, with your position down to 47m on average, after 30 seconds. More than enough to guide the cavalry (green smoke would help too – but doesn’t fit in your pocket, and may raise questions on a date). The iPhone GPS can even work without a data connection (handy also if you are lost in the bush).

GPS Log now has an export to SMS option that allows you to send your GPS position to your friend by SMS. I have also created a stand-alone product focusing on this feature (this is the product that evolved out of the stand-alone “kidney watch” product ideas). http://gpsme.cc/ (if you have GPS Log, no need to try this one)

This is actually a very useful, potentially life-saving feature. Mum tells me the sad story of a guy who died in Queensland when he got lost in the bush. He had cell-phone signal and phoned 000 nine times but they couldn’t find him. 2 floats that could save your life…

The second, more concerning feature is verification.

i-think22 proposes duress words. My only problem with that is that if you are under duress you may not be able to reach your phone. I prefer the Dead Man’s Switch approach where if you don’t perform an action in a fixed timeframe, the cavalry roll in. Of course, both together may provide even more optimal coverage.

The issue with the Dead Man’s Switch is the possibility that your antagonists may intercept the signal and duplicate it (e.g. Speed), or that you may accidently forget to activate the switch, and be rather red-faced when the cavalry roll up.

I would like to see a customised version of the SMS feature, designed for Kidney Watch. So tell me – what should be in it?

dSYM Archive Script

2009-11-13 19:44

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 the order is after the ‘Link Binary With Libaries’ task.

NB. This excludes “Debug” and “Release” build types, as I use “Distribution” and “Distribution Ad-Hoc” for my distribution builds. Easy to change, if you need.

Analysing iPhone Crash Dumps (OS 3.0)

2009-11-13 18:46

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. Make sure your have your dSYM files though – read on.

Useful options for the script are -v (verbose) and -A (just search for Application symbols).

HOWEVER: You MUST keep the dSYM file for every build you do. Even doing a rebuild off the exact same source code produces a dSYM file that is not compatible with the script. So archive those dSYMs!!!

Check out my automatic dSYM script here: dSYM Archive Script

MKDotBounceAnimation animationDidStop bug

2009-11-02 17:08

MKMapViews seem buggy when created problematically.

Some tips:

  1. set the delegate to nil when the delegate dealloc’s, as per that advice to fix one of the crashbugs
  2. 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 calling release directly, I call it after a delay of 4 seconds. This is easy with this statement:

[mapView performSelector:@selector(release) withObject:nil afterDelay:4.0f];

Just gives the internal stuff a chance to clean itself up before the release is sent.

It seems this MKDotBounceAnimation problem only occurs with problematically created MKMapViews (not XIB ones), as my XIB one never seems to crash with that error.

wow, OS X

2009-09-30 22:16

OS X really makes setting up a LAMP service dead easy. I need to do some offline dev (and lets face it, I’m very sick of uploading over slow connections).

Apache and PHP are installed out of the box. Yep – installed *by default* on everyone’s OS X install, not just developers. This is used for the web-sharing feature.

But you have to change one line in Apache to enable the PHP module. This doc was useful (I used vi for everything though, of course). Or the apple docs which make it look harder than it actually is.

Installing MySQL is as simple as downloading the DMG from MySQL.com and running the installer.

And that is is. No ./configure, no make, no make install. Just tweak some settings, and run an installer.

Love it!