转自: https://gist.github.com/igaiga/1354221
| NSData *theImage; |
| } |
| NSData *theImage; |
| uploadImage;
|
| @end |
| |
| |
|
|
| |
| return;}
|
| dataUsingEncoding:NSUTF8StringEncoding]
|
| |
| // Posting constants |
|
|
|
|
| |
| ImageUploader |
| @synthesize theImage; |
| |
| |
| uploadImage
|
| { |
| theImage = uploadImage;
|
| main];
|
| } |
| |
| output
|
| { |
| nil;
|
|
| } |
| |
| dict
|
| { |
| id boundary = BOUNDARY; |
| allKeys]; |
| data]; |
| |
| count]; i++) |
| { |
| objectAtIndex:i]]; |
| dataUsingEncoding:NSUTF8StringEncoding]];
|
| |
| class]]) |
| { |
| // handle image data |
| objectAtIndex:i]]; |
| DATA(formstring)];
|
| appendData:value];
|
| } |
| |
|
| DATA(formstring)];
|
| } |
| |
|
| DATA(formstring)];
|
| return result; |
| } |
| |
| |
| // NSOperationQueueによる非同期化を見据えてmainにしています。 |
| main
|
| { |
| theImage) { |
|
| } |
|
| |
| init]; |
|
|
|
|
| |
| generateFormDataFromPostDictionary:post_dict]; |
| release];
|
| |
|
| URLWithString:baseurl]; |
| requestWithURL:url]; |
|
| |
|
|
|
|
| setHTTPBody:postData];
|
| |
| NSError *error; |
| NSURLResponse *response; |
| error:&error]; |
|
| |
| if (!result) |
| { |
| localizedDescription]]];
|
| return; |
| } |
| |
| // Return results |
| autorelease]; |
|
| cleanup: outstring];
|
| } |
| |
相关文章: