0
Objective-C 및 JSONKit에서 레일스 백엔드에 게시하려고하는데 내 결과를 게시하는 데 어려움이 있습니다. 내 서버에서 null 레코드 세트를 계속 가져옵니다.목표 -C & JSONKit POST 문제
[dictionary setValue:(@"bar") forKey:@"foo"];
NSString *JSON = [dictionary JSONString];
NSData *theData = [JSON dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString: myUrl];
NSString *postLength = [NSString stringWithFormat:@"%d", [theData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
NSError *error = NULL;
NSURLResponse *response = nil;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json-rpc" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:theData];
NSData *result = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
NSString *resultString = [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding];
NSLog(resultString);
내가 빠진 것이 있습니까?
어떤 도움을 크게 감상 할 수 다음 JSON 제대로
{ "바", "foo는"이} 직렬화 것으로 보인다.
감사합니다.
은 : ("바"@), 문제를 안하는, 내가 여기에 이상한 아무것도 표시되지 않습니다. 요청의 cachePolicy를 NSURLRequestReloadIgnoringCacheData로 변경하면 도움이 될 수 있습니다. – Davyd
감사합니다. Davyd.i가 [setCachePolicy : NSURLRequestReloadIgnoringCacheData] 요청을 추가하려고 시도했습니다. 위와 나는 여전히 문제가 있습니다. – mat
서버에서 보내는 데이터를 가져 옵니까? – Davyd