ios - How keep things DRY with afnetworking -


i'm writing ios app has send , receive data api @ various screens in app. each view controller calling code

// afappdotnetapiclient subclass of afhttpclient, defines base url , default http headers nsurlrequests creates [[afappdotnetapiclient sharedclient] getpath:@"stream/0/posts/stream/global" parameters:nil success:^(afhttprequestoperation *operation, id json) {     nslog(@"app.net global stream: %@", json); } failure:nil]; 

i want keep things dry , created requested builder , response handler create request , parse responses. want move api calls 1 class since uses blocks don't know how this.

can explain how done call 1 method enum , params request , nsdictionary without having api calls , blocks in view controllers. thanks

this concern model part of mvc architecture. example project has implementation of this:

post.h

+ (void)globaltimelinepostswithblock:(void (^)(nsarray *posts, nserror *error))block;

define class methods on model take care of making requests (translating method parameters request params) , serializing objects response.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -