I’ve tried the following sample code:
#import "Foundation/Foundation.h"
@interface example
{
@public NSString* name;
}
@end
@implementation example @end
int main()
{
example* me;
me->name = @"World";
}
And it appears my code hates me at this point. I do understand how much of a bad idea it is to make a field public, but I’m not sure why I’m getting an error at that last line in main().
You’re not allocating or initializing your
mevariable. You probably want to inherit fromNSObjectand then use this:At the very least you need to
allocit.