ios - Send parameter to server and get return value in NSString format -
this first time trying.
till successful in getting data server in json format.
now want is, have 2 nsstring
values have send server , server check them. don't know checking mechanism behind. sending 2 strings , server return me try or false. , have show true or false thing.
all called onclick of uibutton
here tried,
nsstring *str = [nsstring stringwithformat:@"http://xxxxxxxxxxxxxxxxxxxxxxx/api/captchaimage/checkcaptchvalid?validstring={%@}&encodestring={%@}",string1,string2]; nsmutableurlrequest *req = [[nsmutableurlrequest alloc] init]; [req seturl:[nsurl urlwithstring:str]]; nsurlconnection *connget = [[nsurlconnection alloc]initwithrequest:req delegate:self]; if(connget) { nslog(@"connected successfully"); } else { nslog(@"not connected successfully"); }
it gives me nslog connected successfully, struck here, want response server in nsstring format, either true or false. can 1 guide me further steps.
i tried links, didn't much.
thanks in advance.
- (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { [mydata appenddata:data]; } -(void)connectiondidfinishloading: (nsurlconnection *)connection { response = [[nsstring alloc] initwithdata:mydata encoding:nsutf8stringencoding]; }
try this, have not tested code. add appropriate delegate method. hope work you
Comments
Post a Comment