でデータを投稿しようとしていましたNSURLConnection
。これは私のコードです:
responseData = [[NSMutableData alloc]init];
self.regData=data;
NSString *postString = [NSString stringWithFormat:@"name=%@&email=%@®Id=%@unique_id=%@",self.regData.name,self.regData.email,self.regData.regId,UNIQUE_ID];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc]initWithURL:url ];
NSData *postData = [postString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[req setHTTPMethod:@"POST"];
[req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-type"];
[req setValue:[NSString stringWithFormat:@"%d",[postData length]] forHTTPHeaderField:@"Content-Length"];
[req setHTTPBody:postData];
(void)[NSURLConnection connectionWithRequest:req delegate:self];
しかし、私はこのような例外を受け取りました
NSInvalidArgumentException', reason: '-[MAAppDelegate connectionFailed]: unrecognized selector sent to instance 0x15d8b310'
*** First throw call stack:
(0x30fbaf53 0x3b2e46af 0x30fbe8e7 0x30fbd071 0x30f0c598 0x19cb83 0x318f43a3 0x318f42e7 0x318f5031 0x319804fd 0x30c280ef 0x30c26ae3 0x30c5831f 0x30eee719 0x30bbec3d 0x30bbeb0d 0x30bbe9a1 0x30f8618b 0x30f8565b 0x30f83e4f 0x30eeece7 0x30eeeacb 0x35bc7283 0x33790a41 0x187dbd 0x3b7ecab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
これを解決してください。