Ive got a project with a NSArray which Ive declared and set property in the .h-file like this:
And in the .m-file Ive synthesized it with:
Now, this should mean that I can use the array anywhere in the .m-file.
The problem is that if I set its value in one function, and tries to extract its value (that I just set in the first function) from another function, it seems to be empty.
Does it have to do with the way I set the property of the array? Ive used "retain" which I thought should mean that it retains its content.
Code:
@interface LeafViewController : UIViewController <UIWebViewDelegate, AVAudioPlayerDelegate, UITabBarControllerDelegate>
{
NSArray *buttonNamesSecondRow;
}
@property (nonatomic, retain) NSArray *buttonNamesSecondRow;
And in the .m-file Ive synthesized it with:
Code:
@synthesize buttonNamesSecondRow;
Now, this should mean that I can use the array anywhere in the .m-file.
The problem is that if I set its value in one function, and tries to extract its value (that I just set in the first function) from another function, it seems to be empty.
Code:
// Setting the arrays content in function 1
- (void)viewWillAppear:(BOOL)animated
{
buttonNamesSecondRow = [NSArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", nil];
}
// Trying to get the arrays content in function 2..
- (void) segmentAction: (id) sender
{
// But array is empty!
NSString *letter = [buttonNamesSecondRow objectAtIndex:2];
}
Does it have to do with the way I set the property of the array? Ive used "retain" which I thought should mean that it retains its content.