NSString * strUrl = @ "URL"; NSURL * url = [NSURL URLWithString: strUrl];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; // For set postdata in string NSString *strPatientID = [NSString stringWithFormat:@"%@%@%@%@",self.txtDegit1.text,self.txtDegit2.text,self.txtDegit3.text,self.txtDegit4.text]; NSString *deviceToken = @""; postString = [NSString stringWithFormat:@"practiceid=%@&email=%@&password=%@&devicetoken=%@",strPatientID,self.txtUsername.text,self.txtPassword.text,deviceToken]; NSMutableData *httpDataBody = [NSMutableData data]; [httpDataBody appendData:[postString dataUsingEncoding:NSUTF8StringEncoding]]; NSString *strPostLength = [NSString stringWithFormat:@"%lu",[httpDataBody length]]; if ([httpDataBody length ] > 0){ [request addValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [request setHTTPMethod:@"POST"]; [request addValue:strPostLength forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:httpDataBody]; } urlConnection = [[NSURLConnection alloc]initWithRequest:request delegate:self]; [urlConnection start];
Chirag Patel
source share