Non-member functions in Objective-C

Posted by Jellyfingers McSlimedessert on Stack Overflow See other posts from Stack Overflow or by Jellyfingers McSlimedessert
Published on 2010-04-18T08:17:41Z Indexed on 2010/04/18 8:23 UTC
Read the original article Hit count: 542

Filed under:
|

I want to write a standalone function in Objective-C; so essentially a C-style function, with Objective-C calls in it. For example:

NSString* someFunc()
{
 NSString* str = [[NSString alloc] init];

 return str;
}

I declare the function in a header file, and define in it a .m file. However, the function doesn't appear to be compiled in, as the linker complains about the missing symbol. I thought that maybe I should put it in a C file, but then of course it spat at me for writing Objective-C Nonsense in BASI... C.

What do?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about c