first post here. I was reading through an Objective-C tutorial earlier, and I saw that they had made a couple of NSString instance variables like this:
@implementation MyViewController {
NSString *stringOne;
NSString *stringTwo;
NSString *stringThree;
NSString *stringFour;
NSString *stringFive;
}
And then simply used them in ViewDidLoad like this:
- (void)viewDidLoad
{
[super viewDidLoad];
stringOne = @"Hello.";
stringTwo = @"Goodbye.";
stringThree = @"Can't think of anything else to say.";
stringFour = @"Help...";
stringFive = @"Pheww, done.";
}
How have they done this without instantiating the string? Why does this work? Surely you'd have to do something like stringOne = [NSString stringFromString:@"Hello."];
to properly alloc and init the object before you could simply do stringOne= @"Hello.";
.
Sorry if this a dumb question, but I find these little things throw me.
Thanks, Mike