Possible Duplicate:
index 0 beyond bounds for empty array error
I am a hobbyist in iOS programming. And I always have the same problem while programming. I think that I don't understand the memory management issue. This is my actual project:
h-File: a NSMutableArray containing NSStrings
NSMutableArray *pictureStrings;
@property (nonatomic,retain) NSMutableArray *pictureStrings;
in the m-File:
@synthesize pictureStrings;
and in the viewDidLoad Method
pictureStrings = [[NSMutableArray alloc] init];
in the dealloc Method
[pictureStrings release];
okay. I am working with an asynchronous URL Request which gets a number of strings and in the connectionDidFinishLoading Delegate Method the values get stored to pictureStrings
[pictureStrings addObject:aString];
BUT when I read values in the cellForRowAtIndexPath Method like
if (pictureStrings != nil) {
cell.textLabel.text = [NSString stringWithFormat:@"%@", [pictureStrings objectAtIndex:indexPath.row]];
}
my App crashes with the message:
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
Where is my fault? Please help me!
Yours, Raphael. Greetings from Austria