Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ASIHTTPRequest的以下代码查询_Iphone_Objective C_Multithreading_Xcode - Fatal编程技术网

Iphone ASIHTTPRequest的以下代码查询

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]

使用以下代码^sign-in的目的是什么

__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调用它

希望这对您有所帮助。

插入符号(^)引入了块文字,大括号括住了组成块体的语句。可以将块视为类似于匿名函数

你应该参考这个