Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-05-2009, 11:19 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 23
Question Custom UITableViewCell issue with XML

Hey I have a custom TableViewCell that I created and load into a tableview that will load an XML file and display the data. The custom cell itself will display but when I try to set the label text in the custom cell to any of the XML data (using the way that was working with the default cell), code breaks.

Both the custom cell and the subclass for the custom cell are called TableViewCell. I believe that I have everything connected up right in Interface Builder because the cell itself will display with no problem. It's just when I try and pass data to a label.

**TableViewCell.h**

@interface TableCellView : UITableViewCell {
IBOutlet UILabel *dateText;
}
@property (nonatomic, retain) IBOutlet UILabel *dateText;
@end

**RootViewController.m**
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath {

static NSString *MyIdentifier = @"TableCellView";

TableCellView *cell = (TableCellView *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableCellView" owner:self options:nil];
cell = tblCell;
}

// Set up the cell
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
[cell setText:[[stories objectAtIndex: storyIndex] objectForKey: @"Date"]]; //This is the line that gives me trouble

//[cell.dateText setText:[[stories objectAtIndex: storyIndex] objectForKey: @"Date"]]; //If I try and set the text like this it breaks.

return cell;
}




Of course any help is very much appreciated. Thanks!
MattTrout is offline   Reply With Quote
Old 10-06-2009, 06:18 AM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Beijing
Posts: 23
Send a message via MSN to gaoning87
Default

Quote:
Originally Posted by MattTrout View Post
Hey I have a custom TableViewCell that I created and load into a tableview that will load an XML file and display the data. The custom cell itself will display but when I try to set the label text in the custom cell to any of the XML data (using the way that was working with the default cell), code breaks.

Both the custom cell and the subclass for the custom cell are called TableViewCell. I believe that I have everything connected up right in Interface Builder because the cell itself will display with no problem. It's just when I try and pass data to a label.

**TableViewCell.h**

@interface TableCellView : UITableViewCell {
IBOutlet UILabel *dateText;
}
@property (nonatomic, retain) IBOutlet UILabel *dateText;
@end

**RootViewController.m**
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath {

static NSString *MyIdentifier = @"TableCellView";

TableCellView *cell = (TableCellView *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableCellView" owner:self options:nil];
cell = tblCell;
}

// Set up the cell
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
[cell setText:[[stories objectAtIndex: storyIndex] objectForKey: @"Date"]]; //This is the line that gives me trouble

//[cell.dateText setText:[[stories objectAtIndex: storyIndex] objectForKey: @"Date"]]; //If I try and set the text like this it breaks.

return cell;
}




Of course any help is very much appreciated. Thanks!
Try this if can be helpful:
int storyIndex = indexPath.row;
cell.textLabel.text = :[[stories objectAtIndex: storyIndex] objectForKey: @"Date"];
gaoning87 is offline   Reply With Quote
Old 10-06-2009, 12:01 PM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 23
Default

Quote:
Originally Posted by gaoning87 View Post
Try this if can be helpful:
int storyIndex = indexPath.row;
cell.textLabel.text = :[[stories objectAtIndex: storyIndex] objectForKey: @"Date"];
Hey thanks for the reply, I'm @ work and can't access our internet from my laptop so I'll try it when I get home. Made the changes and it compiled and ran but I have it downloading the XML, so obviously it didn't return anything. I will post back if it works or not. Thanks again!
MattTrout is offline   Reply With Quote
Old 10-06-2009, 06:22 PM   #4 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 23
Default

Quote:
Originally Posted by gaoning87 View Post
Try this if can be helpful:
int storyIndex = indexPath.row;
cell.textLabel.text = :[[stories objectAtIndex: storyIndex] objectForKey: @"Date"];

Hey that didn't work. Got the same error in console that I keep getting....

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[TableCellView dateText]: unrecognized selector sent to instance 0x575490'

Relatively new to iPhone/Touch programming and don't totally understand the error!
MattTrout is offline   Reply With Quote
Old 02-07-2010, 08:55 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 1
Default

Quote:
Originally Posted by MattTrout View Post
Hey that didn't work. Got the same error in console that I keep getting....

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[TableCellView dateText]: unrecognized selector sent to instance 0x575490'

Relatively new to iPhone/Touch programming and don't totally understand the error!
it is the colon.... do one of these two:

Code:
cell.textLabel.text = [[stories objectAtIndex: storyIndex] objectForKey: @"Date"];
OR
Code:
[cell.textLabel setText:[[stories objectAtIndex: storyIndex] objectForKey: @"Date"]];
mikesilvers is offline   Reply With Quote
Reply

Bookmarks

Tags
interface builder, uitableview, uitableviewcells, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 241
21 members and 220 guests
ADY, AragornSG, bookesp, BrianSlick, Dani77, Dattee, Dominus, dre, glenn_sayers, HemiMG, JasonR, karlam963, nobre84, Oral B, prchn4christ, Raggou, Rudy, spiderguy84, themathminister, viniciusdamone, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:21 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0