ios - Why keep pop up uialert even internet connection is good -
i had put request in viewdidload
have internet connection still pop uialertview
non stop , didn't return value. need put timeout longer time?
asiformdatarequest *request = [asiformdatarequest requestwithurl:url]; __unsafe_unretained asiformdatarequest *_request = request; [request setrequestmethod:@"post"]; [request setpostvalue:@"admin_request_user_join_group" forkey:@"tag"]; [request setpostvalue:groupid forkey:@"group_id"]; [request setpostvalue:userid forkey:@"poster_user_id"]; [request setpostvalue:targetuserid forkey:@"target_user_id"]; [request setdelegate:self]; [request settimeoutseconds:30.0]; [request setshouldattemptpersistentconnection:no]; [request startasynchronous]; [request setcompletionblock:^(void){ nsinteger responsecode = [_request responsestatuscode]; if (responsecode == 200 || responsecode == 201 || responsecode == 202) { nsmutabledictionary *response = (nsmutabledictionary *)[[_request responsestring] jsonvalue]; nsinteger success = [[response objectforkey:@"success"] integervalue]; if (success == 1) { nsmutabledictionary *dict = [myfriendarray objectatindex:sender.tag]; [dict setobject:@"0" forkey:@"join_group_status"]; [myfriendarray replaceobjectatindex:sender.tag withobject:dict]; nsindexpath *rowtoreload = [nsindexpath indexpathforrow:sender.tag insection:0]; nsarray* rowstoreload = [nsarray arraywithobjects:rowtoreload, nil]; } } }]; [request setfailedblock:^(void){ uialertview *alert = [[uialertview alloc] initwithtitle:@"connection failed" message:[nsstring stringwithformat:nslocalizedstring(@"connection_failed", nil)] delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; }];
asiformdatarequest *request = [asiformdatarequest requestwithurl:url]; __unsafe_unretained asiformdatarequest *_request = request; [request setrequestmethod:@"post"]; [request setpostvalue:@"admin_request_user_join_group" forkey:@"tag"]; [request setpostvalue:groupid forkey:@"group_id"]; [request setpostvalue:userid forkey:@"poster_user_id"]; [request setpostvalue:targetuserid forkey:@"target_user_id"]; [request setdelegate:self]; [request settimeoutseconds:30.0]; [request setshouldattemptpersistentconnection:no]; [request startasynchronous]; [request setcompletionblock:^(void){ nsinteger responsecode = [_request responsestatuscode]; if (responsecode == 200 || responsecode == 201 || responsecode == 202) { nsmutabledictionary *response = (nsmutabledictionary *)[[_request responsestring] jsonvalue]; nsinteger success = [[response objectforkey:@"success"] integervalue]; if (success == 1) { nsmutabledictionary *dict = [myfriendarray objectatindex:sender.tag]; [dict setobject:@"0" forkey:@"join_group_status"]; [myfriendarray replaceobjectatindex:sender.tag withobject:dict]; nsindexpath *rowtoreload = [nsindexpath indexpathforrow:sender.tag insection:0]; nsarray* rowstoreload = [nsarray arraywithobjects:rowtoreload, nil]; } } [request setfailedblock:^(void){ uialertview *alert = [[uialertview alloc] initwithtitle:@"connection failed" message:[nsstring stringwithformat:nslocalizedstring(@"connection_failed", nil)] delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; }]; }];
this might you
Comments
Post a Comment