2011-01-03 24 views
0

私はiPhoneの開発者とObject-Cの話題です。なぜ私の 'TableViewController'が '-setNames:'に応答しないかもしれないのか分かりません。なぜ 'TableViewController'が '-setNames:'に応答しない可能性がありますか

ヘッダーファイル

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

@interface FishTableViewController : UITableViewController { 
    NSArray* fishNames; 
} 

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

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

Implementionファイル。

#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]; 
} 

デバッグコンソール出力

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

答えて

5

naming conventions of Cocoa and Cocoa Touchが適切なメソッド名(大文字の違いに注意してください)メソッド名がObjective-Cでは大文字と小文字が区別されsetFishNames:、ないsetfishNames:であることを意味します。

+0

ダン!私は愚かな感じ! 申し訳ありませんが私はそれを逃した。助けてくれてありがとう。 –

+0

@ 5lbバスの心配はありません。しばらくすると、慣習や構文などがかなり深くなってしまいますが、Cocoaのやり方に慣れていくには時間がかかります。 :) –

0

あなたがプロパティとしてfishNamesを合成しているので、あなたも行うことができます。

retController.fishNames = fishSubCategory; 
関連する問題