今天和后台调了很久的接口,因为一些原因老久才弄好.
今天比较满意的事,上传头像的方法,换了个写法,一次就通过,依稀还记得三个月前,为了弄个上传头像的方法,折腾了好一阵子,当时也没好好总结. 发现http://stackoverflow.com 绝对是片段代码的圣地的啊,比如上传头像的这个方法: http://stackoverflow.com/questions/19261481/ios-image-upload-via-afnetworking-2-0
UIImage *image = [infovalueForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image,0.5);
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManagermanager];
NSDictionary *parameters = @{@"foo":@"bar"};
NSURL *filePath = [NSURLfileURLWithPath:@"file://path/to/image.png"];
[manager POST:@"http://example.com/resources.json"parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>formData) {
[formDataappendPartWithFormData:imageData name:@"image"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@",error);
}];
发现周一是头脑最清醒的时刻.不过还是没有总结一个知识点>.<如何才能改变呢?我该不会写100天的日记吧?
从明天开始一个主题来总结吧,不能再写日记了…..