我正在遵循 Alasdair Allan 第 91 页的 Learning iOS Programming 第 2 版书中的代码。我正在尝试将表格视图输出信息到文本视图。在我添加此代码之前,其他一切都有效。delegate.cities 引用了 AppDelegate 中称为城市的 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;
}