Wednesday, June 22, 2011

@selectors in obj-c

elector in Objective C
In short, Selector can either be a name of method or a message to an object when used in the source code. And SEL is the complied form of a Selector.










- (void) fooNoInputs {
NSLog(@"Does selector test");
}

- (void) fooOneInput:(NSString*) first {

// NSLog(@"Does selector test");
NSLog(@"my slectore Logs %@", first);
}

- (void)viewDidLoad
{


//
//##############################################################################

// SELCETOR test

//##############################################################################




[self performSelector:@selector(fooNoInputs)];

[self performSelector:@selector(fooOneInput:) withObject:@"firstc"];













############## difference between

[self playButtonSound]; &

[self performSelector:@selector(playButtonSound)];







Both to the same thing, but [self playButtonSound]; is definitely the normal way to invoke a method in Objective-C. However, using performSelector: allows you to call a method that is only determined at runtime.

No comments:

FEEDJIT Live