views:

53

answers:

2

My apologies in advance for what is probably a really dumb question. I'm familiar (or at least getting familiar) with instance and 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?

To clarify how I ended up in this position, I started using these methods in a "utilities" class of mine after reading some online blog describing the author's preference for declaring these functions this way. Now I can't seem to track down a more detailed explanation of what exactly the differences are, etc.

+2  A: 

These are c functions that wrap objective-c functions.

Kevin Sylvestre
+1  A: 

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.

Chuck