NSArray loses data

Discussion in 'iOS Programming' started by Jeremy1026, Jun 26, 2009.

  1. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #1
    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:
    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
    	}
    }
     
  2. Jeremy1026 thread starter macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #2
    Solved by member of another board.

     

Share This Page