iOS is case sensitive

I was finishing my last project yesterday and to my surprise found that, after thorough tests in the iOS Simulator, that the app heavily crashes on the iDevice.

After a few checks in the debugger I discovered the root cause of the issue - I was assigning an image to imageView and its validity was tested using ZAssert macro as follows:

ZAssert(self.portraitBackgroundImage != nil, @"Portrait image is nil");

If you don't know ZAssert macro, you're missing a big help in tracing of your code. I found it on Marcus Zarra's blog as follows:


#ifdef DEBUG

#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])

#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]

#else

#define DLog(...) do { } while (0)

#ifndef NS_BLOCK_ASSERTIONS

#define NS_BLOCK_ASSERTIONS

#endif

#define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])

#endif

#define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)


In my code, I have had a following statement:

p0205.portraitBackgroundImage = [UIImageimageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"p0205_p"ofType:@"JPG"]];

Do you notice uppercase JPG? It works without a glitch in the simulator, but not on the iDevice! The only reason is that iOS is case sensitive system. Didn't notice it before...

Dotazy? Komentáře? Chtěli byste aplikaci pro iPhone? Kontaktujte mne!