您好,
我正在尝试使用以下示例代码发送带有NSUrlconnection
的json对象...
应用程序在到达最后一行后崩溃:[[NSURLConnection alloc] initWithRequest:request delegate:self];
任何想法?
答案 0 :(得分:3)
- (void)setHTTPBody:(NSData *)data
需要NSData *才能工作
尝试:
NSData *requestdata = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:requestData];
答案 1 :(得分:0)
+ (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
。