This is my second day programming in ObjectiveC so I apologize for the noob question.
I have a ViewController that does an API call using async and asihttprequest:
@synthesize loadingStatus;
- (void)loadStatsData
{
[indicator setHidden:NO];
loadingStatus = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"bad", nil] forKeys:[NSArray arrayWithObjects:@"amount", nil ] ];
[RESTApiController request:@"/method.json" method:@"GET" options:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObject:@"amount"] forKeys:[NSArray arrayWithObject:@"receiving"] ] parent:self];
}
and receiving it like this:
- (void)requestFinished:(ASIHTTPRequest *)request
{
if (receiving == @"amount")
{
// do stuff
[loadingStatus setValue:@"good" forKey:@"amount"];
}
if ([loadingStatus valueForKey:@"amount"] == @"good"])
[indicator setHidden:YES];
}
The app crashes when it tries to use the loadingStatus variable in requestFinished(). I guess somehow the variable gets dellocated, but I'm unsure as how to approach this.
Two questions: 1) How can I keep loadingStatus's state across methods calls so I can use it in the way I wrote the code 2) Is there a better way of achieving my goal of checking if API calls are completed and hiding the ActivityIndicator?
-M.