I have a NSURLConnection which I am calling every time -(void)viewWillAppear:animated
is called (that's only for now, it's just for testing)
I am doing it like this
receivedData = [[NSMutableData data] retain];
NSString *urlString = @"<URL hidden>";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0];
[NSURLConnection connectionWithRequest:request delegate:self];
Then I have these three delegate methods:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *returnString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
usersPhotos = [[NSMutableArray alloc] initWithArray:[[returnString JSONValue] objectForKey:@"data"]];
[self loadAnnotations];
NSLog(@"%@", returnString);
[returnString release];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[self loadAnnotations];
}
Even though I am sure the returnString
should change (I can visit the site in urlString
and confirm it has changed) it is always the same.
It is as if it reuses the data that it retrieves from the first connection.
Does anyone know why this is?