ios把block添加到字典中
-(void)uploadAlbum:(NSArray *)imageArray describe:(NSString *)describe{
__blockNSMutableArray *resultArray = [NSMutableArrayarray];
ImageToDataStrComplete handleBlock = Block_copy(^{
DataPacket *dataPacket = [[DataPacket alloc] init]
NSMutableDictionary *dic = [NSMutableDictionarydictionary];
[dic setObject:describe forKey:@"describes"];
[dic setObject:resultArray forKey:@"collection"];
dataPacket.strContent = [dic JSONRepresentation] ;
[[BusServiceinstance] postRequire:dataPacket];
[dataPacket release];
}
);
NSDictionary *varDic = [NSDictionary dictionaryWithObjectsAndKeys:imageArray,@"oriImages",resultArray ,@"resultArray",handleBlock,@"block",nil];
[self performSelectorInBackground:@selector(handleImageDataOnBackGrounpThread:) withObject:varDic];
Block_release(handleBlock);
}
-(void)handleImageDataOnBackGrounpThread:(NSDictionary *)varDic{
NSArray *images = [varDic objectForKey:@"oriImages"];
ImageToDataStrComplete handleBlock = [varDic objectForKey:@"block"] ;
NSMutableArray *resultArray = [varDic objectForKey:@"resultArray"];
for(UIImage *image in images){
NSDictionary *imageDic = [HomiUtildictionaryWithBinaryFormatFromImage:image suffixStr:@"png"];
[resultArray addObject:imageDic];
}
handleBlock();
}
posted on 2012-09-17 16:17 kiao295338444 阅读(1520) 评论(0) 编辑 收藏 举报