我试图学习如何使用 sql 数据源,我在苹果的示例中找到了一个示例名称 SQLiteTutorial 太糟糕了,苹果没有更新他们的示例,所以当我打开苹果示例文件时,我收到了许多不推荐使用的警告...... .
在这种情况下,代码是
// 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,但我没有找到解决方法。
我正在处理的教程在这里:http ://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/
我在应用程序委托中有其他警告
// 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:cache not found
/ 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;
}
谢谢,如果你有答案。