On Github jmburges / Random-ObjC-Features
Created by Joe Burgess
LLVM: Modern extensible compilerCLang: C language family frontend for LLVM
Why don't more people use these?
NSNumber *fortytwo = @42 NSNumber *pi = @3.1415926535
Add in f for float and a l for long
NSNumber *fortytwoLong = @42L NSNumber *pi = @3.1415926535F
NSNumber *threeOverTwo = @(3 / 2);
NSArray *array = @[ @"Hello", @"World"];
NSArray *dictionary = @{ @"message" : @"Hello, World!" @"sender" : @"Joe Burgess" };
These are all immutable
array[0]=@"bar"Custom Keyed Subscripting
dictionary[@"foo"]=@"bar"
- (id)objectAtIndexedSubscript:(NSUInteger)idx; - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
- (id)objectForKeyedSubscript:(id )key; - (void)setObject:(id)obj forKeyedSubscript:(id )key;
[[class[@"teachers"] lastObject] firstName]
just like methodMissing in Ruby
-(NSMethodSignature*)methodSignatureForSelector:(SEL)sel
-(void)forwardInvocation:(NSInvocation*)inv
Tells Objective-C the method signature just like in your header files
Actually does the method.
struct { double lat; double long; } point
@interface point : NSObject { @public @property double lat; @property double long; } @end
#define MAX_USERS ((int) 42)
// in a header extern const int MAX_USERS; // in a C file const int MAX_USERS = 42;
@import MapKit.MKMapView
You can't. Only Apple can. Lame.