UITableView deprecated setText in iPhone SDK 3.0

May 24, 2010 § Leave a comment

By default Navigation-based app use UITableView.

In RootViewController.m, you would declare the no. of row in tableView: method. Here you increase the row from 0 to 1 to display one row.

// Customize the number of rows in the table view.
– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1; // Modify from 0 to 1
}

cell.text and setText: are deprecated in iPhone SDK 3.2. It would give you warning but error in red.

So don’t use:

[cell setText:@”Next View”];

cell.text = @”Next View”;

Use cell.textLabel.text = @”Next View”;

// Customize the appearance of table view cells.
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @”Cell”;

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Added
cell.textLabel.text = @”Next View”;

// Configure the cell.
return cell;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading UITableView deprecated setText in iPhone SDK 3.0 at Web Builders.

meta

%d bloggers like this: