我正在尝试使用JSON将数据发送到服务器。 我能够创建带有对象和关键参数的NSDictionary。 但是我想发送我的图片,而这张图片是UIImage。
NSDictionary* mainJSON = [NSDictionary dictionaryWithObjectsAndKeys:
@"John",
@"First_Name",
@"McCintosh",
@"Last_name",
<HERE I WANT PICTURE>,
@"Profile_picture",
nil];
// Here I convert to NSDATA
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:mainJSON options:NSJSONWritingPrettyPrinted error:&error];
// Sending operation :
dispatch_async(kBgQueue, ^
{
NSData * data = [NSData dataWithContentsOfURL:@"addresSERVER"];
[self performSelectorOnMainThread:@selector(receivedResponseFromServer:)
withObject:data
waitUntilDone:YES];
}
);
我在想如何将我的照片添加到NSDictionary中?因为我想发送照片的内容。如果我添加UIImage对象...那么我会发送整个对象,对吗?
谢谢