自定义Operation
1、创建一个类继承为NSOperation
2、自定义NSOperation的具体操作要写在main strat 里面,才会执行里面的操作
-(void)main{
NSLog(@".......");
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
UIImage *image = [UIImage imageWithData:data];
NSLog(@"%@", image);
}
2、初始化自定义的Operation
DownLoadOperation *downLoadOperation = [[DownLoadOperation alloc]initWithDownLoadMessageURL:@"http://file.bmob.cn/M01/37/F1/oYYBAFXdo8yAFY8QAABIFt81XEM849.png"];
其他的使用方法与系统自带的NSOperation是一样的