gpt4 book ai didi

iphone - Objective C 成员引用基类型错误

转载 作者:行者123 更新时间:2023-11-29 11:10:44 25 4
gpt4 key购买 nike

我正在遵循 Alasdair Allan 编写的 Learning iOS Programming 2nd Edition 书中的代码,第 91 页。我正在尝试将 TableView 输出信息输出到 TextView 。在我添加此代码之前,其他一切都有效。 delegate.cities 引用 AppDelegate 中名为 cities 的 NSMutableArray。

我认为这可能与 objectAtIndex 期望 NSUInteger 有关,但书上说要发送它 index.rowindex 属于 NSIndexPath 类型,它位于我导入此类的 SimpleView 类中。 rowNSInteger 类型,所以我假设问题是这本书要我在它期望时发送 objectAtIndex 一个带符号的整数一个无符号整数。那会是他的问题吗?如果是这样,我该如何解决?

错误信息:成员引用基类型 'char (const char,int)' 不是结构或联合

这是我的功能:

-(void)viewDidLoad
{
[super viewDidLoad];

AppDelegate *delegate =
(AppDelegate *)[[UIApplication sharedApplication] delegate];

City *thisCity = [delegate.cities objectAtIndex:index.row]; //error with index.row

self.title = thisCity.cityName;
}

最佳答案

系统头文件 string.h 中的全局函数 index() 定义的签名类似于错误 (char* (const char *, 整数)).编译器似乎认为您正在尝试将 那个函数 作为结构或联合访问(即通过在其上使用 .row,这是您可以对结构执行的操作).

显然,您的类中没有名为 index 的字段(我猜您没有显示该类),或者编译器以某种方式错误地解析了它。使用正确的字段名称或使用类似 self->index.row 的名称来消除歧义。

关于iphone - Objective C 成员引用基类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11712578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com