Iphone ASIHTTPRequest的以下代码查询
使用以下代码^sign-in的目的是什么Iphone ASIHTTPRequest的以下代码查询,iphone,objective-c,multithreading,xcode,Iphone,Objective C,Multithreading,Xcode,使用以下代码^sign-in的目的是什么 __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:sourceURL]; [request setCompletionBlock:^{ NSLog(@"Image downloaded."); NSData *data = [request responseData]; image = [[UIImage alloc]
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:sourceURL];
[request setCompletionBlock:^{
NSLog(@"Image downloaded.");
NSData *data = [request responseData];
image = [[UIImage alloc] initWithData:data];
[[NSNotificationCenter defaultCenter] postNotificationName:@"com.razeware.imagegrabber.imageupdated" object:self];
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"Error downloading image: %@", error.localizedDescription);
}];
^符号表示代码块,因为整个函数是按自身编写的,而不是创建方法并使用@selector调用它 希望这对您有所帮助。插入符号(^)引入了块文字,大括号括住了组成块体的语句。可以将块视为类似于匿名函数 你应该参考这个