Challenge
Your challenge is to add this code to your project:
// Add this function to the top of AppDelegate.m
static BOOL different (int thing1, int thing2) {
return thing1 - thing2;
}
// Add this method inside application:didFinishLaunchingWithOptions
if (different(1, 2) == YES) {
NSLog(@"Different!");
} else {
NSLog(@"Not different.");
}
Run your code on both 32-bit iOS and 64-bit iOS. It should correctly display “Different” on one, but not the other. Why?
Then replace your if statement with the following:
if (different(1, 2)) {
NSLog(@"Different!");
} else {
NSLog(@"Not different.");
}
Run this on both 32-bit and 64-bit iOS. Why is this version better practice than the previous?
Download solution
Helpful links
Errata
- I misspoke around the 18 second mark – I meant to say “lowercase bool” but said “lowercase boolean”.