i am trying to send json array data to server but it show the result is failed. so plaese correct me where i did wrong.Here is code what i am using in this:
NSDictionary *dict=@{@"groupmembersarray":contactsArray};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString *post = [NSString stringWithFormat:@"%@",jsonString];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://anaadit.net/caffe/newapp/AddGroupContact.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(conn==nil) {
NSLog(@"Connection could not be made");
} else {
responseData = [NSMutableData new];
NSLog(@"%@",responseData);
}
and nsurl connection delegate methods calling but the response is showing is nil . so please check and correct me .Thanks in advance.