I have the following design pattern query problem. I have a web service in PHP from which I want to perform, log in authorisation, and SQL operations, some with NSDictionary responses, and some with BOOL responses.
I have had a search for design patterns and hit this: Best architectural approaches for building iOS networking applications (REST clients)
Now although this post is very interesting, I don't think I need anything as complicated. I have started with a singleton object as a assetDBConnection, but I don't know whether this is the best idea.
The only way I can think of having my assetDBConnection abstracted away from my APIWebRetrieve data retriever is to pull out and compare strings from the response. See below:
-(void)APIWebRetrieveFinished:(APIWebRetrieve *)api
{
NSLog(@"api:%@",[api description]);
NSLog(@"%@",api.dataString);
NSError *error;
if (api.dataString) {
NSDictionary *results=[NSJSONSerialization JSONObjectWithData:[api.dataString dataUsingEncoding:NSStringEncodingConversionAllowLossy]
options:NSJSONReadingMutableContainers
error:&error];
[self.delegate assetDBresult:results];
if ([[results objectForKey:@"type"] isEqualToString:@""]){
//Check for string key here
}
}
}
Any help appreciated.
Aucun commentaire:
Enregistrer un commentaire