Xcode - 在 64 位中编译应用程序时出现错误

Xcode - Error occurs when compiling app in 64-bit

我正在使用 Xcode 并将我的应用更改为在 32 位和 64 位中编译,这导致出现错误。

我收到错误: "Multiple methods named "count" 找到不匹配的结果、参数类型或属性"

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return [self.sections count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [[self.sections objectAtIndex: section]  count];
}

我认为这是由于 64 位版本不再将它们视为同一类型造成的。

错误发生在第二个函数中。这是简单类型转换的问题吗?如果是这样,我应该将 'count' 投射到什么?

谢谢大家。

编译器不知道这个对象响应了哪个方法。您发送 "count" 消息。编译器遍历它所知道的所有 类 的所有计数方法。如果超过两个不同的,它就得报错了。

你可以写

NSArray *tempArray=[self.sections objectAtIndex: section];
return [tempArray  count];