Learning Cocoa with Objective-C by Paris Buttfield-Addison

Learning Cocoa with Objective-C

6.4/101 min read

5/5/20

  • Use NSNumber to store numbers in NSArrays and NSDictionaries: @123

  • int myValue = [theNumber intValue];

  • NSNumber *number = @(a + 1);

  • Blocks allow you to store chunks of code in variables and call them later

  • You must copy a block to be able to access it after a method

  • In order to modify a variable, that is declared outside of the block, inside the block you must mark the variable with the __block keyword

  • A frame rectangle is defined relative to its superview

  • Bounds rectangle is the view's position and size relative to its own coordinate space

  • for (NSString* key in dictionary) { NSObject* theValue = [dictionary objectForKey:key]; [aProduct setValue:theValue forKey:key]; }

  • If you try to set a value for a key that does not exist in your class, the key-value coding system will throw an exception because the runtime won’t know where to store the value

  • Notifications come with a special aps dictionary which contains information about how the push notification should be presented