HTTPBody
/*!
@abstract Sets the request body data of the receiver.
@discussion This data is sent as the message body of the request, as
in done in an HTTP POST request.
*/
@property (nullable, copy) NSData *HTTPBody;
iOS 数据转 json data
- (NSData *)toJSONData:(id)obj{
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted error:&error];
if ([jsonData length] > 0 && error == nil){
return jsonData;
}else{
return nil;
}
}
网友评论