Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 4, 2009, 03:40 PM   #1
XcodeNewb
macrumors member
 
Join Date: Feb 2009
unrecognized selector sent to instance ** plz help

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
XcodeNewb is offline   0 Reply With Quote
Old Apr 4, 2009, 04:37 PM   #2
newb16
macrumors regular
 
Join Date: Feb 2008
Is cell2 actually an instance of CustomCell when desc property is accessed?
newb16 is offline   0 Reply With Quote
Old Apr 4, 2009, 06:33 PM   #3
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Did you remember to connect the UILabel to the desc property in Interface Builder?
__________________
dejo is offline   0 Reply With Quote
Old Apr 5, 2009, 04:03 AM   #4
eclipse82
macrumors newbie
 
Join Date: Nov 2008
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.
eclipse82 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
"Unrecognized selector" error when attempting to remove an object while in a for loop moonman239 iPhone/iPad Programming 18 Feb 26, 2014 08:29 AM
Resolved: [_NSCFNumber setTableViewStyle:] unrecognized selector set to instance moonman239 iPhone/iPad Programming 2 Nov 18, 2013 07:14 PM
Resolved: Unrecognized selector sent to instance Blakeasd iPhone/iPad Programming 2 Jul 2, 2013 09:01 PM
unrecognized selector sent to instance with Coredata and Category of NSMangedObject roeik iPhone/iPad Programming 5 Sep 5, 2012 06:40 AM
unrecognized selector larswik iPhone/iPad Programming 6 Jun 20, 2012 11:46 PM

Forum Jump

All times are GMT -5. The time now is 09:32 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC