i’m trying to code up a simple table view > detail app to start getting familiar with obj-c. i use a dictionary to popolate the table, than clicking on a cell i get to a blank detail view. this work (i say it proudly). things get worst when i try to send information to the detail view, here’s the debug error i get:
2012-07-12 14:32:41.906 StoryboardTutorial[79624:f803] -[UIView setText:]: unrecognized selector sent to instance 0x6eae8d0
2012-07-12 14:32:41.908 StoryboardTutorial[79624:f803] Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIView setText:]: unrecognized selector sent to instance 0x6eae8d0’*
**First throw call stack:
(0x13ca022 0x155bcd6 0x13cbcbd 0x1330ed0 0x1330cb2 0x2d41 0xdba1e 0xdbd11 0xed8fd 0xedaef 0xeddbb 0xee85f 0xeee06 0xc8a852d 0xeea24 0x27bd 0xa55c5 0xa57fa 0x93a85d 0x139e936 0x139e3d7 0x1301790 0x1300d84 0x1300c9b 0x12b37d8 0x12b388a 0x14626 0x1c4d 0x1bb5 0x1)
terminate called throwing an exception(lldb)
and here’s some chunks of code:
DetailViewController.h
// DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController{
NSString *city;
NSString *state;
IBOutlet UILabel *cityLabel;
IBOutlet UILabel *stateLabel;
}
@property (nonatomic,retain) NSString *city,*state;
@property (retain,nonatomic) IBOutlet UILabel *cityLabel,*stateLabel;
@end
DetailViewcontroller.m
// DetailViewController.m
#import "DetailViewController.h"
@implementation DetailViewController
@synthesize city,state,cityLabel,stateLabel;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
stateLabel.text = state;
cityLabel.text = city;
}
ViewController.m
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
detail.city = [dataSource objectAtIndex:indexPath.row];
detail.state = [states objectForKey:detail.city];
[self.navigationController pushViewController:detail animated:YES];
UITableViewCell *cell;
cell = [tableView cellForRowAtIndexPath:indexPath];
cell.textLabel.shadowColor = [UIColor clearColor];
}
- (void)setupArray{
states = [[NSMutableDictionary alloc] init];
[states setObject:@"Roma" forKey:@"Lazio"];
[states setObject:@"Milano" forKey:@"Lombardia"];
dataSource = [states allKeys];
}
UIViewdoesn’t have asetTextmethod. TheUIViewyou’re talking to needs to have a propertytextin order to have a methodsetTextThe error is most likely in one of these lines
One of these must not be the type of object you think it is (aka a
UIViewinstead of aUILabel). Unless you’re callingsetTextsomewhere else.Try changing it to