2011-03-14 3 views
0

안녕하세요, 저는 고등학교에서 아이폰 프로그래밍에 대한 독립적 인 연구를하고 있습니다. 나는 선생님 "Head First Iphone Programming"에서 책을 받았습니다. 아무런 문제없이 첫 번째 강의 (버튼으로 안녕하세요 세계)를 끝내었지만 지금은 두 번째 강의로 넘어갑니다. 옵션을 표시하기 위해 UIPickerview를 사용하는 트위터 응용 프로그램입니다. 나는 UIPickerview에 나타나기 위하여 무엇이든을 얻을 수 있지 않았다.책에서 iPhone 프로그래밍. 클래스 'InstatwitViewController'의 구현이 불완전합니다.

내 InstatwitViewController.h 보이는 같은 :

#import <UIKit/UIKit.h> 
@interface InstatwitViewController : UIViewController 
<UIPickerViewDataSource, UIPickerViewDelegate> { 
    NSArray* activities; 
    NSArray* feelings; 
} 
@end 

내 InstaTwitViewController.m은 다음과 같습니다

#import "InstatwitViewController.h" 

@implementation InstatwitViewController 

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 
    return 2; 
} 
- (NSInteger)pickerView:(UIPickerView *)pickerViewNumberOfRowsInComponent : (NSInteger)component { 
    if (component == 0) { 
     return [activities count]; 
    } 
    else { 
     return [feelings count]; 
    } 
} 

하고 ....

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    activities = [[NSArray alloc] initWithObjects:@"Sleeping", @"eating", @"working", @"thinking", @"crying", @"begging", @"leaving", @"shopping", @"hello worlding", nil]; 
    feelings = [[NSArray alloc] initWithObjects:@"awesome", @"sad", @"happy", @"ambivalent", @"nauseous", @"psyched", @"confused", @"hopeful", @"anxious", nil]; 
} 

및 ....

- (void)dealloc { 
    [activities release]; 
    [feelings release]; 
    [super dealloc]; 
} 

IB에 들어가서 마우스 오른쪽 버튼을 클릭하여 파일 소유자에게 데이터 소스를 끌었습니다. 책에서 말한 것처럼 다음에 실행할 때 .. 검은 화면이 표시됩니다. 이것은 클래스이며, 완전한 멍청한 놈 메신저와 나는 한 달 주위에 여기 갇혀했기 때문에

을 heres 내 디버거

[Session started at 2011-03-14 18:48:17 -0400.] 
GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May 5 04:36:56 UTC 2010) 
Copyright 2004 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB. Type "show warranty" for details. 
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all 
Attaching to process 10220. 
2011-03-14 18:48:19.411 Instatwit[10220:207] -[InstatwitViewController pickerView:numberOfRowsInComponent:]: unrecognized selector sent to instance 0x5c164e0 
2011-03-14 18:48:19.415 Instatwit[10220:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[InstatwitViewController pickerView:numberOfRowsInComponent:]: unrecognized selector sent to instance 0x5c164e0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x0238c919 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x024da5de objc_exception_throw + 47 
    2 CoreFoundation      0x0238e42b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x022fe1b4 ___forwarding___ + 1124 
    4 CoreFoundation      0x022fdcd2 _CF_forwarding_prep_0 + 50 
    5 UIKit        0x002a7072 -[UIPickerView _delegateNumberOfRowsInComponent:] + 159 
    6 UIKit        0x0045033f -[UITable dataSourceGetRowCount] + 47 
    7 UIKit        0x004502e9 -[UITable numberOfRows] + 54 
    8 UIKit        0x0044e9d8 -[UITable floatArray:getValueCount:gapIndexCount:] + 34 
    9 UIKit        0x0034bbb5 -[UIFloatArray _setupWithDataProvider:valueIsSingleton:singletonValue:isRefresh:] + 68 
    10 UIKit        0x0034bb6b -[UIFloatArray refreshWithDataProvider:singleValue:] + 64 
    11 UIKit        0x004500d7 -[UITable setRowHeight:] + 160 
    12 UIKit        0x002a6201 -[UIPickerTable setRowHeight:] + 61 
    13 UIKit        0x004520e1 -[UITable _reloadRowHeights] + 199 
    14 UIKit        0x0044ff71 -[UITable noteNumberOfRowsChanged] + 99 
    15 UIKit        0x00454a0e -[UITable reloadData] + 439 
    16 UIKit        0x002ab301 -[UIPickerView layoutSubviews] + 4052 
    17 QuartzCore       0x0401c0d5 -[CALayer layoutSublayers] + 177 
    18 QuartzCore       0x0401be05 CALayerLayoutIfNeeded + 220 
    19 QuartzCore       0x0401b64c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 302 
    20 QuartzCore       0x0401b2b0 _ZN2CA11Transaction6commitEv + 292 
    21 UIKit        0x002b363f -[UIApplication _reportAppLaunchFinished] + 39 
    22 UIKit        0x002b3a68 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 545 
    23 UIKit        0x002bd452 -[UIApplication handleEvent:withNewEvent:] + 1958 
    24 UIKit        0x002b6074 -[UIApplication sendEvent:] + 71 
    25 UIKit        0x002baac4 _UIApplicationHandleEvent + 7495 
    26 GraphicsServices     0x02bf2afa PurpleEventCallback + 1578 
    27 CoreFoundation      0x0236ddc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    28 CoreFoundation      0x022ce737 __CFRunLoopDoSource1 + 215 
    29 CoreFoundation      0x022cb9c3 __CFRunLoopRun + 979 
    30 CoreFoundation      0x022cb280 CFRunLoopRunSpecific + 208 
    31 CoreFoundation      0x022cb1a1 CFRunLoopRunInMode + 97 
    32 UIKit        0x002b3226 -[UIApplication _run] + 625 
    33 UIKit        0x002beb58 UIApplicationMain + 1160 
    34 Instatwit       0x00001f18 main + 102 
    35 Instatwit       0x00001ea9 start + 53 
    36 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 
Program received signal: “SIGABRT”. 
(gdb) 

도움은 좋은 것입니다.

감사합니다.

+0

당신이 말하는 코드 스 니펫은 InstantwitViewController.h가 InstantwitViewController.m이라고하는 것과 같습니다. 실제 .h 파일을 게시 할 수 있습니까? – Walter

+0

@Walter 그것을 잡아 주어서 고맙다, 나는 그것을 고쳤다. – user659680

답변

2

위임 방법에 공백이 없습니다. 사용 :

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 
    if (component == 0) { 
     return [activities count]; 
    } 
    else { 
     return [feelings count]; 
    } 
} 
+0

팁 주셔서 고마워요,하지만 내 프로그램을 빌드 할 때, 그것은 3 경고를 얻을 A) 클래스 'InstatwitViewController'의 구현이 불완전 B) '-pickerView : numberOfRowsInComponent :'에 대한 메소드 정의가 없습니다. C) 'InstatwitViewController'클래스가 없습니다. 'UIPickerViewDataSource'프로토콜을 완벽하게 구현하십시오. 이러한 것들이 내 .m 파일의 일부분처럼 느껴집니다. Ctrl 키를 누른 상태에서 클릭했을 때 내 IB에서 파일이 맞지 않을 수도 있습니다. – user659680

+0

.h 파일에도 오류가 있습니다. 를 구현해야합니다. 가 있어야합니다. 나는이 것들이 대소 문자를 구별한다는 것을 확신한다. – gnuchu

관련 문제