a3116b
a3116b

Reputation: 337

setText : is deprecated

i tryed to learn how working with a sql data source, i've find a sample name SQLiteTutorial in apple's sample What bad, apple did not update their samples, so when i open apple sample file i've got many deprecated warning ....

in that case the code is

// Set up the cell
    SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate];
    Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row];

    [cell setText:animal.name];
    return cell;  

and Xcode said me setText is deprecated, but i did not find how to correct this.

The tutorial i'm working on is here : http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/

I've got other warning in the app delegate

// 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 tell me that SQLiteTutorialAppDelegate may not respond to checkAndCreateDatabase and to readAnimalsFromDatabase

and the last thing in the RootViewController , instance method initWithData:cache not found

enter image description here

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

}

thanks if you have an answer.

Upvotes: 1

Views: 2487

Answers (2)

omz
omz

Reputation: 53561

The documentation is always a good start to look for how to replace deprecated methods:

The text of the cell. (Deprecated in iOS 3.0. Use the textLabel and detailTextLabel properties instead.)

As for your other warnings, you've probably forgotten to declare the readAnimalsFromDatabase and checkAndCreateDatabase methods in your header file.

Upvotes: 1

Filip Radelic
Filip Radelic

Reputation: 26683

cell.textLabel.text = animal.name;

Is how you set text in the cell since iOS 3.0.

Don't know about other warning because they are related to the code You didn't post. Learning from such old code is not a good idea, you should probably find something slightly newer :)

Upvotes: 3

Related Questions