如何在块中返回数组?

时间:2015-10-11 09:24:05

标签: ios objective-c nsarray afnetworking-2

这是我的代码

+(NSArray)getItem:(NSString)searchString {
NSArray *testArray = [[NSArray alloc] init];

NSString *searchURL = [NSString stringWithFormat:@"http://server.com/item/autocomplete_item.php?term=%@", searchString];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager GET:searchURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
  //  NSLog(@"item response object : %@", responseObject);
    testArray = (NSArray*)responseObject;
    //[self getItemArray:(NSArray*)responseObject];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error : %@", error);
}];

return testArray;
}

但我得到一个错误说:

variable is not asssignable(missing_block type specifier)

请有人帮助我。提前谢谢。

0 个答案:

没有答案