Objective C selector tutorial

In php to do dynamic typing you do something like

$key = 'id';
$assoc = array('id' => 1);
echo $assoc[$key];

In objective c you would use a selector.

SEL key = @selector(id)

//or
//SEL key = NSSelectorFromString(@"id");

//Then
NSDictionary *assoc =
[NSDictionary dictionaryWithObjectsAndKeys: @"1", @"id", nil];
NSLog([assoc performSelector: key]);

If you have setters and getters

-(void)children;
-(void)setChildren:(NSArray *) newChildren;

Syndicate content