2011-04-30 5 views
1

'[치료 수퍼]를 인식 할 수없는 선택기 인스턴스 0x4e3b7b0로 전송') 은 상기 탭의 하나에있는 TableView 넣어 다음 코드를 삽입하고이 오류를 얻을엑스 코드 'NSInvalidArgumentException', 이유 : - : 나는 내가 5 개 탭 (컴파일 및 실행을 만든 일반 탭 표시 줄 응용 프로그램을 만들어이 오류 을 받고있는 이유 확실하지 않다

cure.h

#import <UIKit/UIKit.h> 

@interface cure : UIViewController 
<UITableViewDataSource, UITableViewDelegate> 
{ 
    NSArray *exercises; 
} 

@end 

cure.m

#import "cure.h" 

@implementation cure 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 1; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 

    // create a cell 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] 
       initWithStyle:UITableViewCellStyleDefault 
       reuseIdentifier:@"cell"]; 
    } 

    // set the main text 
    cell.textLabel.text = [exercises objectAtIndex:indexPath.row]; 

    // return the cell. 
    return cell; 
} 


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    exercises = [[NSArray alloc] 
       initWithObjects:@"An Interesting Title", 
       @"A Not That Interesting Title", 
       @"And Still Another Title", nil]; 

    [super viewDidLoad]; 
} 



- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

- (void)viewDidUnload { 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 


- (void)dealloc { 
    [super dealloc]; 
} 

@end 
mainwindows.xib 에서

내가 오른쪽 탭 클래스 이름 "치료"

오류 내가 잘못하고있는 무슨

2011-04-29 22:22:06.446 week 3 week clear [4950:40b] -[cure superview]: unrecognized selector sent to instance 0x4e3b7b0 
2011-04-29 22:22:06.451 peek 3 week clear [4950:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[cure superview]: unrecognized selector sent to instance 0x4e3b7b0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x00dc15a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x00f15313 objc_exception_throw + 44 
    2 CoreFoundation      0x00dc30bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x00d32966 ___forwarding___ + 966 
    4 CoreFoundation      0x00d32522 _CF_forwarding_prep_0 + 50 
    5 UIKit        0x002e2365 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 77 
    6 UIKit        0x002e0aa3 -[UIView(Hierarchy) addSubview:] + 57 
    7 UIKit        0x002e87c1 -[UIView initWithCoder:] + 840 
    8 Foundation       0x00017c24 _decodeObjectBinary + 3296 
    9 Foundation       0x00016d91 _decodeObject + 224 
    10 UIKit        0x004ac979 -[UIRuntimeConnection initWithCoder:] + 212 
    11 Foundation       0x00017c24 _decodeObjectBinary + 3296 
    12 Foundation       0x000189f5 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1354 
    13 Foundation       0x00019024 -[NSArray(NSArray) initWithCoder:] + 596 
    14 Foundation       0x00017c24 _decodeObjectBinary + 3296 
    15 Foundation       0x00016d91 _decodeObject + 224 
    16 UIKit        0x004abc36 -[UINib instantiateWithOwner:options:] + 804 
    17 UIKit        0x004adab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 
    18 UIKit        0x00363628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70 
    19 UIKit        0x00361134 -[UIViewController loadView] + 120 
    20 UIKit        0x0036100e -[UIViewController view] + 56 
    21 UIKit        0x00373f54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120 
    22 UIKit        0x00372aaa -[UITabBarController transitionFromViewController:toViewController:] + 64 
    23 UIKit        0x003748a2 -[UITabBarController _setSelectedViewController:] + 263 
    24 UIKit        0x00374711 -[UITabBarController _tabBarItemClicked:] + 352 
    25 UIKit        0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119 
    26 UIKit        0x004b3ce6 -[UITabBar _sendAction:withEvent:] + 422 
    27 UIKit        0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119 
    28 UIKit        0x00341799 -[UIControl sendAction:to:forEvent:] + 67 
    29 UIKit        0x00343c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
    30 UIKit        0x00341750 -[UIControl sendActionsForControlEvents:] + 49 
    31 UIKit        0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119 
    32 UIKit        0x00341799 -[UIControl sendAction:to:forEvent:] + 67 
    33 UIKit        0x00343c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
    34 UIKit        0x003427d8 -[UIControl touchesEnded:withEvent:] + 458 
    35 UIKit        0x002d5ded -[UIWindow _sendTouchesForEvent:] + 567 
    36 UIKit        0x002b6c37 -[UIApplication sendEvent:] + 447 
    37 UIKit        0x002bbf2e _UIApplicationHandleEvent + 7576 
    38 GraphicsServices     0x01719992 PurpleEventCallback + 1550 
    39 CoreFoundation      0x00da2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    40 CoreFoundation      0x00d02cf7 __CFRunLoopDoSource1 + 215 
    41 CoreFoundation      0x00cfff83 __CFRunLoopRun + 979 
    42 CoreFoundation      0x00cff840 CFRunLoopRunSpecific + 208 
    43 CoreFoundation      0x00cff761 CFRunLoopRunInMode + 97 
    44 GraphicsServices     0x017181c4 GSEventRunModal + 217 
    45 GraphicsServices     0x01718289 GSEventRun + 115 
    46 UIKit        0x002bfc93 UIApplicationMain + 1160 
    47 peek 3 week clear     0x00002658 main + 102 
    48 peek 3 week clear     0x000025e9 start + 53 
) 
terminate called after throwing an instance of 'NSException' 
Program received signal: “SIGABRT”. 

있나요? 감사합니다.

답변

2

인터페이스 빌더의 "ID"탭에있는 UIView에 "치료"클래스가 지정되었을 것입니다. "cure"는 뷰 컨트롤러이므로 UIView 메서드 (예 : -superview)를 구현하지 않으므로 펜촉을로드하려고 할 때 예외가 발생합니다.

Btw, 코드에서 누수가 많이 발생했습니다. Objective-C의 메모리 관리에 대해 읽어보십시오. (아마도 Cocoa 명명 규칙에 대해서도).

+0

답장을 보내 주셔서 감사합니다. 튜토리얼을 던져서 메모리 링크를 위해 몇 가지 클래스에 대해 배울 것입니다. 하나의 테이블 뷰에 코드를 추가하기 위해 탭 중 하나에서 코드를 약간 변경하고 있습니다. 그들 중 탭. 나는 그것이 어떻게 설정되어야 하는지를 정말로 잘 모르겠다. 테이블 뷰에서 cure.h cure.m 클래스의 데이터를로드하려는 경우 xib 파일 이름은 dacure.xib이며 프로 시저는 무엇입니까? 감사 – borgy2

관련 문제