1

SQL データ ソースの操作方法を学ぼうとしたところ、Apple のサンプルに SQLiteTutorial というサンプル名が見つかりました。悪いことに、Apple はサンプルを更新していないため、Apple のサンプル ファイルを開くと、多くの非推奨の警告が表示されます ... .

その場合、コードは

// 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 が見つかりません

ここに画像の説明を入力

/ 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;

}

答えがあればありがとう。

4

2 に答える 2

3
cell.textLabel.text = animal.name;

iOS 3.0 以降、セルにテキストを設定する方法です。

あなたが投稿しなかったコードに関連しているため、他の警告についてはわかりません。そのような古いコードから学ぶのは良い考えではありません。おそらく少し新しいものを見つけるべきです:)

于 2011-08-07T21:07:41.230 に答える
1

ドキュメンテーションは、廃止されたメソッドを置き換える方法を探すための良い出発点です。

セルのテキスト。(iOS 3.0 では非推奨。代わりに textLabel および detailTextLabel プロパティを使用してください。)

その他の警告については、ヘッダー ファイルでメソッドreadAnimalsFromDatabaseとメソッドを宣言するのを忘れている可能性があります。checkAndCreateDatabase

于 2011-08-07T21:13:32.663 に答える