У меня здесь довольно необычная проблема. Приведенный ниже код работает нормально, и данные отправляются источнику в порядке, но ни один из триггеров NSURLConnection ничего не возвращает. Регистрируются только те элементы, в которых отправляется запрос. Есть идеи?
// code starts above here
NSData *myRequestData = [ NSData dataWithBytes: [ requestString UTF8String ] length: [ requestString length ] ];
NSURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlPrefix]];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: myRequestData];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
NSURLResponse *resp = nil;
NSError *err = nil;
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse: &resp error: &err];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
if (!theConnection)
{
NSLog(@"Failed to submit request");
}
if(theConnection)
{
NSMutableData* receivedData=[[NSMutableData data] retain];
NSLog(@"Created connection.");
NSLog(@"--------- Request submitted ---------");
NSLog(@"receivedData: %@", receivedData);
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"Received response: %@", response);
NSLog(@"Received response, connection retain count is %d",[connection retainCount]);
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSLog(@"Connection received data, retain count: %d", [connection retainCount]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSLog(@"finished connection retain count: %d", [connection retainCount]);
}