I started developing iPhone apps a couple of months ago. I started with no object-c knowledge at all. So all is new for me. Although I’ve learned a lot, I still do not get some of the ‘inconsistency’ of apple regarding the simulator and device difference. I’ve written down some of my notes below. Keep in mind that I’m not an expert but maybe you’ll find these notes useful.
1) Comparing strings give problems on the Device.
This works on the Simulator but not on the device:
[[blobMutableArray objectAtIndex:r] objectAtIndex:i] == [NSString stringWithFormat:@"2"]
[NSString stringWithFormat:@"%@",[[myMutableArray objectAtIndex
a +1)] objectAtIndex
b+offset)]] == [NSString stringWithFormat:@"%d",colorCheck]
This is the correct code for the Simulator and device:
[[[blobMutableArray objectAtIndex:r] objectAtIndex:i]intValue] == 2
[[[myMutableArray objectAtIndex
a +1)] objectAtIndex
b +offset)]intValue] == colorCheck
2) Crash Lander Sound sample class error in the simulator.
After implementing the Crash Lander openAL sound class from apple and when you want to set different values like:
SoundEngine_LoadBackgroundMusicTrack or SoundEngine_Initialize the simulator crashed. Note that the device handles it correct. I use the same code line as the example of apple..
My workaround on this one is pretty simple but effective:
#if !TARGET_IPHONE_SIMULATOR
// my sound settings
#endif
if you have an solution to get openAl working on the simulator please let us know.
3) UUID mismatch
warning: UUID mismatch detected with the loaded library – on disk is:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/lib/liblockdown.dylib
=uuid-mismatch-with-loaded-file,file=”/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/lib/liblockdown.dylib”
some users (say that) they has fixed it by reinstalling xcode. For me it wasn’t the solution. The warning only popup in the device debugger and has no side effects we know of.
4) int and float calculations
I don’t know of this is different in the device or simulator but I notice some problems in calculations with integers.
for example;
int x = 440;
int y = 270;
float F = x / y;
gives as result = 1.000
to fix this I do;
int x = 440;
int y = 270;
float F = (100 *x) / y;
F = F /100;
Just one of those tiny details you can spent enough time on..
5) _sound or sound: it’s a big difference..
Some errors may occur when you use a _ character before the “sound” tag in your code. I noticed this because apple’s sample code uses _sound.
6) NSLog and For loops really slow down your app
First I thought the For loops where using a lot of memory, but then after clearing all my NSlog, ( I had a couple of them ) especially in the for loops, the app is now just as fast as the simulator. So keep in mind that it slows down your app, and for accurate testing you must comment the NSlogs.
7) Multi-language files does not change
Each time you change a multi-language file, for example an image, you must clean your project otherwise the files are cached and shows only the original language file.
8) sdk 2.2 ibtool failed with exit code 5
A bug in interface builder gives the error “sdk 2.2 ibtool failed with exit code 5 ” to correct this, recheck all the hidden objects to visible. Then you can continue, and after building, recheck it again to hidden.
9) compare string values
string1 == string2 does sometime works and sometimes not. Therefore use [string1 isEqualToString:string2] instead, just to make sure it always works.
float values can be compared the same for example:
NSString *string1 = [NSString stringWithFormat:@"%.3f", floatValue]
10) Save defaults before exit
I noticed that default values are not saved directly (if you use them). That can cause problems when you are quitting your app with exit(0); then your defaults are not saved. To sync your defaults directly use:
[[NSUserDefaults standardUserDefaults] synchronize];
June 21st, 2009
1 Comment at "iPhone development notes"
Great information – I didn’t realize that NSLog slowed things down so much. Wish there was a way to leave them in there but globally turn them off.
Comment Now!