0
其實我有JSON參數後的圖像使用多到URL
[dictionary setObject:_dateOfBirth.text forKey:@"birth_date"];
[dictionary setObject:_tfCountry.text forKey:@"country"];
[dictionary setObject:_tfEmail.text forKey:@"email"];
[dictionary setObject:@"" forKey:@"fromLogin"];
[dictionary setObject:@1 forKey:@"gender"];
[dictionary setObject:@"signup" forKey:@"methodName"];
[dictionary setObject:_tfContact.text forKey:@"mobile"];
[dictionary setObject:_tfName.text forKey:@"name"];
[dictionary setObject:_tfNickName.text forKey:@"nickname"];
[dictionary setObject:_tfPassword.text forKey:@"password"];
[dictionary setObject:_tfPinCode.text forKey:@"pincode"];
也有一個形象,我必須設置profile_pic爲重點。 現在我已經轉換了所有的參數作爲數據和POST數據躺在這
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:kNilOptions error:nil];
// this is your service request url
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://proteen2.inexture.com/webservice"]];
// set the content as format
[request setHTTPMethod:@"POST"];
[request setHTTPBody: jsonData];
// this is your response type
[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"content-type"];
NSError *err;
NSURLResponse *response;
// send the synchronous connection
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
// here add your server response NSJSONSerialization
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:responseData options: NSJSONReadingMutableContainers error: &err];
它的作品爲文本精細,現在怎麼圖片附加到參數,我只知道用多聲部,但沒有得到該點。請幫助
檢查:http://stackoverflow.com/questions/8042360/nsdata-and-uploading-images-via-post-in-ios –
什麼是邊界?如果我將圖像轉換成NSdata如何將該數據添加到該參數引用到特定鍵。我很困惑 –