Different method types?
I'm familiar (or at least getting familiar) with instance and开发者_Python百科 class methods in objective-c, but have also seen method implementations that look like this:
#import "Utilities.h"
#import "CHAPPAppDelegate.h"
#import "AppState.h"
@implementation Utilities
CHAPPAppDelegate* GetAppDelegate() {
return (CHAPPAppDelegate *)[UIApplication sharedApplication].delegate;
}
AppState* GetAppState() {
return [GetAppDelegate() appState];
}
@end
What are these? While I'm sure this is documented somewhere, I don't know what term to use in searching for an explanation of what's being done here. I like the syntax methods like this let me use when calling them, but I'm not sure exactly what I'm doing, what the implications are, how to send parameters to these types of functions, etc?
These are c functions that wrap objective-c functions.
Those aren't methods at all. They are just functions, exactly like in normal C. They aren't part of the class. The body of the functions are written in Objective-C (i.e. the functions send messages to objects), but functions themselves are completely independent of objects and Objective-C.
精彩评论