0
votes

I'm a noob to iPhone dev and Object-C. Not sure why my 'TableViewController' may not respond to '-setNames:' Any help would be appreciated.

Header File

#import <UIKit/UIKit.h>
#import "FishViewController.h"

@interface FishTableViewController : UITableViewController {
    NSArray* fishNames;
}

+ (FishTableViewController*) fishTableViewControllerWithFishNames:(NSArray*)fishSubCategory;

@property (nonatomic, retain) NSArray* fishNames;
@end

Implemention file.

#import "FishTableViewController.h"

#define FishTableViewControllerNibName @"FishTableViewController"

@implementation FishTableViewController

@synthesize fishNames;

+ (FishTableViewController*) fishTableViewControllerWithFishNames:(NSArray*)fishSubCategory {
    // Warning occurs on the following line
    FishTableViewController* retController = [[FishTableViewController alloc] initWithNibName:FishTableViewControllerNibName bundle:nil];

    [retController setfishNames:fishSubCategory];

    return [retController autorelease];
}

Debug Console Output

2011-01-03 13:06:21.287 FishID[826:207] -[FishTableViewController setfishNames:]: unrecognized selector sent to instance 0x5d0d340
2011-01-03 13:06:21.289 FishID[826:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FishTableViewController setfishNames:]: unrecognized selector sent to instance 0x5d0d340'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0238e919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x024dc5de objc_exception_throw + 47
    2   CoreFoundation                      0x0239042b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x02300116 ___forwarding___ + 966
    4   CoreFoundation                      0x022ffcd2 _CF_forwarding_prep_0 + 50
    5   FishID                              0x00002a75 +[FishTableViewController fishTableViewControllerWithFishNames:] + 116
    6   FishID                              0x000028d7 -[RootViewController tableView:didSelectRowAtIndexPath:] + 252
    7   UIKit                               0x00324718 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
    8   UIKit                               0x0031affe -[UITableView _userSelectRowAtIndexPath:] + 219
    9   Foundation                          0x00031cea __NSFireDelayedPerform + 441
    10  CoreFoundation                      0x0236fd43 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
    11  CoreFoundation                      0x02371384 __CFRunLoopDoTimer + 1364
    12  CoreFoundation                      0x022cdd09 __CFRunLoopRun + 1817
    13  CoreFoundation                      0x022cd280 CFRunLoopRunSpecific + 208
    14  CoreFoundation                      0x022cd1a1 CFRunLoopRunInMode + 97
    15  GraphicsServices                    0x02bf32c8 GSEventRunModal + 217
    16  GraphicsServices                    0x02bf338d GSEventRun + 115
    17  UIKit                               0x002c0b58 UIApplicationMain + 1160
    18  FishID                              0x00002370 main + 102
    19  FishID                              0x00002301 start + 53
    20  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
2

2 Answers

5
votes

The naming conventions of Cocoa and Cocoa Touch mean that the proper method name is setFishNames:, not setfishNames: (note the capitalization difference) Method names are case sensitive in Objective-C.

0
votes

Since you're synthesizing fishNames as a property, you can also do:

retController.fishNames = fishSubCategory;