Сбой приложения после отправки объекта json - PullRequest
0 голосов
/ 07 ноября 2011

enter image description here

Привет, я пытаюсь отправить объект json с NSUrlconnection с этим примером кода ниже ... приложение вылетает после того, как она нажала последнюю строку: [[NSURLConnection alloc] initWithRequest:request delegate:self];

есть идеи?

Ответы [ 2 ]

3 голосов
/ 07 ноября 2011
- (void)setHTTPBody:(NSData *)data

нужен NSData * для работы

Попробуйте:

NSData *requestdata = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:requestData];
0 голосов
/ 07 ноября 2011
+ (id)dataWithBytes:(const void *)bytes length:(NSUInteger)length   

bytes:
A buffer containing data for the new object.
length:
The number of bytes to copy from bytes. This value must not exceed the length of bytes.

Первый аргумент не NSString, и вы предоставляете NSString.

...