September 2002
Intermediate to advanced
1272 pages
31h 12m
English
Several runtime functions are commonly used in Cocoa applications. The NSStringFromSelector(SEL) function converts selectors into strings. The following line of code can be placed in any method implementation to output the name of the method:
NSLog(@"%@", NSStringForSelector(_cmd));
The NSSelectorFromString(NSString *) function returns the selector if any that corresponds to a string.
The NSClassFromString(NSString *) function returns the class identified by a string name. The following lines of code can be used to send a user specified message to a user specified class object:
void MYSendMessageToAClass(NSString *className, NSString *messageName) { [NSClassFromString(className) performSelector: NSSelectorFromString(messageName)]; ...Read now
Unlock full access