So I have a generic question. I have a bunch of functions, some of which are void, some which return NSString*, some which return NSDictionary*, etc. I use these functions in a bunch of different classes. I want to just create a library .m file that I can include in the classes that use them, so I don’t have to copy and paste these functions all over the place. I’m pretty sure this shouldn’t be hard to do but I can’t seem to get this to work for anything but void functions.
Example:
//Library.h
(NSString*)doStuff{
NSString* test = "hello world";
return test;
}
(void)print{
NSLog(@"Hi");
}
I wish to basically have 1 file that I can just use an import statement on, but am uncertain if this is possible in obj c.
Robin
You can use the plain old C style:
Or, you can use the category feature to attach to existing frameworks: