Blocking
-(User *) Finduser: (NSNumber *) UserID
{
NSString *url = [NSString stringwithformat:@ "%@/s/account/find-user/", Serverbaseurl];
Nsmutabledictionary *requestparms = [[Nsmutabledictionary alloc] init];
[Requestparms setobject:userid forkey:@ "UserID"];
Afjsonrequestserializer *requestserializer = [Afjsonrequestserializer serializer];
Nsmutableurlrequest *request = [Requestserializer requestwithmethod:@ "POST" Urlstring:url parameters:requestParms Error:nil];
Afhttprequestoperation *requestoperation = [[Afhttprequestoperation alloc] initwithrequest:request];
Afhttpresponseserializer *responseserializer = [Afjsonresponseserializer serializer];
[Requestoperation Setresponseserializer:responseserializer];
[Requestoperation start];
[Requestoperation waituntilfinished];
Nsdictionary *userinfo = [[requestoperation responseobject] objectforkey:@ "user"];
if (userInfo! = nil) {
Here the results are processed
return xxxx
}
return nil;
}
Asynchronous
NSString *url = [NSString stringwithformat:@ "%@/s/account/signin/", Serverbaseurl];
Nsmutabledictionary *requestparms = [[Nsmutabledictionary alloc] init];
Setting parameters
[Requestparms setobject:loginname forkey:@ "LoginName"];
[Httpmanager Post:url Parameters:requestparms
success:^ (afhttprequestoperation *operation, id responseobject) {
Success
} failure:^ (Afhttprequestoperation *operation, Nserror *error) {
Failed
}];
This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1772532
Synchronous asynchronous request under IOS afnetworking