In the myProj.h file I have declared:
@property (strong, nonatomic) NSMutableArray *wordsArray;
in the .m file I use the following to add some values in viewDidLoad:
[_wordsArray addObject:[NSString stringWithFormat:@"Now is the time for all good men to come to the aid of their party."]];
[_wordsArray addObject:[NSString stringWithFormat:@"Four score and seven years ago our forefathers..."]];
[_wordsArray addObject:[NSString stringWithFormat:@"A coward dies many deaths; a brave man but one."]];
I also set a counter here (defined as an int in the .h file):
__cntr = 0;
In the (IBAction)pressButton:(id)sender I want to change the label (*somelabel) text to the next value in the array [0] (then iterate _cntr to 1 and get that value, etc). So I have:
_somelabel.text = [NSString stringWithFormat:@"%@",[_wordsArray objectAtIndex:__cntr]];
Builds but when I run and press the button the label text turns to (Null).
So is the problem with the addition of the values to the array or pulling them out. Thanks
wordsArray? Do other classes set the array or get values from it? If not, it shouldn't be a public property.