2011-01-03 10 views
0

Ich bin ein Noob iPhone Dev und Object-C. Ich bin mir nicht sicher, warum mein 'TableViewController' nicht auf '-setNames' reagiert: 'Jede Hilfe wäre willkommen.Warum reagiert 'TableViewController' nicht auf '-setNames:'

Header-Datei

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

@interface FishTableViewController : UITableViewController { 
    NSArray* fishNames; 
} 

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

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

UMSETZUNG Datei.

#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-Konsole 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”.

Antwort

5

Die naming conventions of Cocoa and Cocoa Touch bedeuten, dass die richtige Methode Name setFishNames:, nicht setfishNames: (man beachte die Großdifferenz) Methodennamen Groß- und Kleinschreibung in Objective-C.

+0

Dang! Ich fühle mich dumm!!! Entschuldigung, das habe ich verpasst. Danke für die Hilfe. –

+0

@ 5lb Bass keine Sorgen. Nach einer Weile werden die Konventionen und die Syntax nicht mehr tief verwurzelt, aber es dauert etwas, sich an Cocoas Art der Ausführung zu gewöhnen. :) –

0

Da Sie fishNames als Eigenschaft zu synthetisieren, können Sie auch tun:

retController.fishNames = fishSubCategory; 
Verwandte Themen