I have an NSArray declared in my .h, given a property, and synthesized. I put objects into the array, then log the count (51). I later log the count and its 0. Why am I losing my array data?
Declaring the array data:
Logging the array data down the road
Declaring the array data:
Code:
NSString *FeedURL = @"...aURL...";
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:FeedURL]];
NSURLResponse *resp = nil;
NSError *err = nil;
NSData *response = [NSURLConnection sendSynchronousRequest: theRequest returningResponse: &resp error: &err];
NSString *theString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
tempArray = [theString componentsSeparatedByString:@"<br>"];
if (err == nil) {
for (int i = 0; i < [tempArray count]; i++) {
NSLog(@"%@",[tempArray objectAtIndex:i]);
}
NSLog(@"Connected For SHIZZLE!!!!");
}
else {
NSLog(@"AHH, oops?");
tempArray = [NSArray arrayWithObjects:@"Internet connection required", nil];
}
NSLog(@"temp count - %i",[tempArray count]); //returns 51
Logging the array data down the road
Code:
- (void) changeView {
if (theIndexPath == 4) {
[window addSubview:twitterController.view];
NSLog(@"temp count - %i",[tempArray count]);//returns 0
}
}