Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

XcodeNewb

macrumors member
Original poster
Feb 6, 2009
79
0
I have a navigation controlled app that display's different table views as you navigate down the path. I decided that I wanted to show a CustomCell instead of the regular default cells provided for the grouped style table.

I created the CustomCell.h and CustomCell.m files along with the CustomCell.xib nib file.

I have done this MANY times before in other projects but this one will not let me set any of the fields on the CustomCell. I have stipped this cell down to just one data element called 'desc' and it is a UILabel I am trying to set.

Here is the CustomCell.h file and some of the .m file using the CustomCell class.


Code:
#import <UIKit/UIKit.h>


@interface CustomCell : UITableViewCell {
	IBOutlet UILabel *desc;
}


@property (nonatomic, retain) IBOutlet UILabel *desc;

@end


Code:
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
    CustomCell *cell2 = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];

	if (cell2 == nil) 
	{
		NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
		cell2 = [nib objectAtIndex:0];
	}

      ...do some logic

     cell2.desc.text = [NSString stringWithFormat:@"%@", myText];   //ERROR OCCURS HERE

     return cell2;



I receive the following error:

Code:
4/4/09 2:27:20 PM todo[1484] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSObject desc]: unrecognized selector sent to instance 0x5239b0'

The links are all set in IB and the CustomCell is set to be of Class "CustomCell"

Anyone have any idea why I cannot set the value of the UILabel for the cell2 object?

Thanks in advance
 

newb16

macrumors regular
Feb 27, 2008
100
0
Is cell2 actually an instance of CustomCell when desc property is accessed?
 

eclipse82

macrumors newbie
Nov 15, 2008
2
0
Hi there,

I think the problem lies with the variable 'myText'. The unrecognised selector is being reported when 'myText' is asked for its description.

What kind of variable is 'myText'? if it is an NSString then you want to use the following, [myText UTF8String], this will pass a properly formatted string.

Hope this helps, if not can you post the rest of the code that declares all your variables so we can get a better idea what it going on.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.