I am trying to use an AFNetworking class to retrieve data from a database. Long story short, the data received from the parameter responseObject
is filled with items. Here is my problem however. I am trying to copy the results in responseObject
into an NSDictionary
called results
. I used the following code to get there:
__block NSDictionary *results;
[manager GET:@"http://daneolog.altervista.org/app/getData.php"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) { results = responseObject;
NSLog(@"Inside: %@", results); }
failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"%@", error); }];
NSLog(@"Outside: %@", results);
I tried NSLog
ing the results
dictionary INSIDE the success braces, and everything is a-okay there.
I tried NSLog
ing the results
dictionary OUTSIDE the GET function, and it comes up as (null).
These are my results:
2015-11-12 14:34:34.875 TestApp[4864:258743] Outside: (null)
2015-11-12 14:34:35.242 TestApp[4864:258743] Inside: (
{
address = "Sample Address";
}
)
Now notice the peculiar thing: the outside NSLog is being executed first. I don't know why this is so. Can anyone help me on this? Thanks a bundle.