【发布时间】:2014-03-05 09:17:23
【问题描述】:
我有一个类似
的网址"assets-library://asset/asset.PNG?id=2B9DB56C-B9C6-4F4E-AD51-8A5E5F1DD2AA&ext=PNG"
在“图像”数组中。我如何通过这个 url 从媒体获取 NSData? 我需要在这段代码中使用 NSData:
#pragma mark VK methods
+(NSMutableArray*)attachmentIds:(NSArray*)images forMe:(NSDictionary*)me{
NSMutableArray *attachmentsList = [NSMutableArray new];
for (int i = 0; i<images.count; i++){
NSData *imageData = [NSData dataWithContentsOfURL:[images objectAtIndex:i] ];
NSString *serverUrl = [self getServerForVKUploadPhotoToWall:me];
NSDictionary *uploadResult = [self sendVKPOSTRequest:serverUrl withImageData:imageData];
NSString *hash = [uploadResult objectForKey:@"hash"];
NSString *photo = [uploadResult objectForKey:@"photo"];
NSString *server = [uploadResult objectForKey:@"server"];
NSString *attach_id = [self getVKAttachIdforUser:me photo:photo server:server hash:hash];
[attachmentsList addObject:attach_id];
}
return attachmentsList;
}
但是NSData *imageData = [NSData dataWithContentsOfURL:[images objectAtIndex:i]];
不工作;
【问题讨论】:
标签: ios