I am having some problems with NSString retaining. My problem is that on the second function (runItem) it doesn't seem to picking up on the value of the item1. No matter what I set it to, it seems that it is just set to nil. I am programming for Cocoa (desktop, versus iPhone), and I haven't had this type of problem with NSString before. I'm not sure what I'm doing to cause it, so if anyone can help me on this I would really appreciate it! My code in my AppController.h file:
@interface AppController : NSObject {
NSString *item1;
}
@property (retain) NSString *item1;
- (IBAction)runItem:(id)sender;
@end
And AppController.m:
@synthesize item1;
- (void)awakeFromNib: {
NSDictionary *savedFile = [NSDictionary dictionaryWithContentsOfFile:@"Users/me/Desktop/Testing.plist"];
if (savedFile != nil) {
item1 = [savedFile objectForKey:@"Item Title"];
AppController *runFunction = [[AppController alloc] init];
[runFunction runItem:self];
}
else {
item1 = nil;
}
}
- (IBAction)runItem:(id)sender
NSLog(@"%@", item1);
}