We can use the third frame afnetworkingto communicate with the server usingits post method. If the server returns a userId of ten , it succeeds, and the returned one represents either a user name or a password error.
<span style= "FONT-SIZE:14PX;" >-(void) login: (ID) sender{ afhttprequestoperationmanager *manager=[ Afhttprequestoperationmanager manager]; nsstring *[email protected] "http ://172.18.144.248:8080/upload_file_service/loginservlet "; manager.responseserializer.acceptablecontenttypes=[nsset setwithobjects:@ "Text/html",nil]; nsdictionary *[email protected]{@ "user": @ "admin" @ "pass": @ "123"}; [manager post:url parameters:namepwd success:^ (afhttprequestoperation * Operation, id responseobject) { nslog (@ "post-->%@", Responseobject); nsdictionary *datare=[[nsdictionary alloc] init]; datare=responseobject; re=[datare objectforkey:@ "UserId"]; appstatus *transvalue=[appstatus shareinstance]; mainviewcontroller *mainview=[self.storyboard instantiateviewcontrollerwithidentifier:@ "Second "]; mainview.delegate=self; transvalue.contextstr=__ name.text; nsnumber *fre=[[nsnumber alloc]initwithint:10]; BOOL flag=[fre isEqualToNumber:re]; if (flag) { [self presentviewcontroller: mainview animated:yes completion:nil]; } } failure:^ (Afhttprequestoperation *operation, nserror *error) { nslog (@ "%@", @ "username or password error"); }]; }</span>
iOS Implementation Login Verification