【发布时间】:2012-07-29 20:16:30
【问题描述】:
我正在遵循 Alasdair Allan 第 91 页的《学习 iOS 编程第 2 版》一书中的代码。我正在尝试将表格视图输出信息到文本视图。在我添加此代码之前,其他一切都有效。 delegate.cities 引用了 AppDelegate 中名为 citys 的 NSMutableArray。
我认为这可能与 objectAtIndex 期待 NSUInteger 有关,但书上说要发送它index.row。 index 属于 NSIndexPath 类型,它位于我导入此类的 SimpleView 类中。 row 是 NSInteger 类型,所以我假设问题是这本书希望我在期望时发送 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;
}
【问题讨论】:
-
整数转换自动发生。这是无关的/无关的。我确定您使用
NSIndexPath index而不是NSIndexPath *index。
标签: iphone objective-c ios