setText:已弃用
问题描述:
我试图学习如何使用SQL数据源,我在苹果示例中找到示例名称SQLiteTutorial 什么不好,苹果没有更新它们的样本,所以当我打开苹果示例文件时,已经在这种情况下,得到了许多过时的警告....setText:已弃用
代码
// Set up the cell
SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate];
Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row];
[cell setText:animal.name];
return cell;
和Xcode中说我的setText已过时,但我没有找到如何纠正这一点。
我有其他的警告在应用程序委托
// Execute the "checkAndCreateDatabase" function
[self checkAndCreateDatabase];
// Query the database for all animal records and construct the "animals" array
[self readAnimalsFromDatabase];
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
的Xcode告诉我,SQLiteTutorialAppDelegate可能不checkAndCreateDatabase回应,并readAnimalsFromDatabase
和RootViewController中的最后一件事,实例方法initWithData:找不到缓存
/ Load the animals image into a NSData boject and then assign it to the UIImageView
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[animal imageURL]]];
UIImage *animalImage = [[UIImage alloc] initWithData:imageData cache:YES];
self.animalView.animalImage.image = animalImage;
}
感谢,如果你有一个答案。
答
cell.textLabel.text = animal.name;
从iOS 3.0开始,您是如何在单元格中设置文本的。
不知道其他的警告,因为它们都涉及到代码你没有张贴。从这些旧的代码中学习是不是一个好主意,你应该找到一些稍微新一点:)
答
的documentation始终是一个良好的开端,寻找如何更换过时的方法:
的文本细胞。 (不推荐使用iOS中3.0。使用为textLabel和 detailTextLabel属性,而不是。)
至于你的其他的警告,你可能已经忘记了申报在头文件中的readAnimalsFromDatabase
和checkAndCreateDatabase
方法。
感谢您的回答,很明显如此。在他们的回答中,很多人忘记了英语不是我的母语,而且我是初学者,有时候他们的答案对我来说是中国人。谢谢 – a3116b