xcode “被调用的对象类型 NSString 不是函数或函数指针”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8767455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Called object type NSString is not a function or function pointer" error?
提问by blake305
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
self.cellIdentifier = [self.brain returnCellIdentifier:indexPath];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:self.cellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = [self.brain enchantmentCellText:indexPath];
return cell;
}
I have no idea why I am getting this error. The error seems to come from the line that my cursor is on. How can I fix this error:
我不知道为什么会收到此错误。错误似乎来自我的光标所在的行。我该如何解决这个错误:
Semantic issue
Called object type 'NSString *' is not a function or function pointer
回答by Josh Sherick
I had this exact same error and discovered it was caused because I had created an array manually by typing out all of it's elements, and had forgotten a comma in between two of them.
我遇到了完全相同的错误,并发现这是因为我通过键入所有元素手动创建了一个数组,并且忘记了其中两个之间的逗号。
回答by Ryan Crews
I'm not entirely sure why you have that error, but if you don't have a need for the cell identifier to be different (which it doesn't appear you do) you may want to change that line your cursor is on to the more standard:
我不完全确定您为什么会出现该错误,但是如果您不需要不同的单元格标识符(您似乎没有这样做),您可能希望将光标所在的那一行更改为更标准:
static NSString *CellIdentifier = @"Cell";
which would change your other lines to something closer to:
这会将您的其他行更改为更接近于:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}
The error itself may come from the method of your "brain" object that your calling. If you post that we may be able to tell.
错误本身可能来自您调用的“大脑”对象的方法。如果您发布该信息,我们可能会知道。
~ Good Luck
~ 祝你好运