我从之前的Stack Overflow问题中找到了这个piece of code,该问题描述了如何将多个参数传递给performSelectorInBackground方法。
但是我很难将代码应用到我的问题中,这是我的代码:
- (void)callingMethod {
NSDictionary * args = [NSDictionary dictionaryWithObjectsAndKeys:
cell, @"cell",
storyIndex, @"storyIndex",
nil];
[self performSelectorInBackground:@selector(setCellImageWrapper:)
withObject:args];
}
- (void)setCellImageWrapper:(NSDictionary *)args {
[self setCellImage:[[args objectForKey:@"cell"]]
withIndex:[[args objectForKey:@"storyIndex"] intValue]];
}
- (void) setCellImage: (EventTableCell *)cell withIndex:(int)storyIndex {
//My Code
}
正如您所看到的,我正在尝试将setTableCell类型的对象从setCellImageWrapper方法传递给setCellImage方法。当我尝试调用setCellImage -withIndex方法时,我收到错误“Expected Identifier”。谁能告诉我我做错了什么?
谢谢,
杰克
答案 0 :(得分:5)
如果删除
周围的额外括号[args objectForKey:@"cell"]
它应该编译好