开发者

iPhone Programming from book. incomplete implementation of class 'InstatwitViewController'

开发者 https://www.devze.com 2023-02-16 16:31 出处:网络
Hey everyone, im doing an independent study of iphone programming in my high school.i got a book from a teacher \"Head First Iphone Programming\".I got through the first lesson (hello world with a but

Hey everyone, im doing an independent study of iphone programming in my high school. i got a book from a teacher "Head First Iphone Programming". I got through the first lesson (hello world with a button) without any problems, but now im onto the second lesson. It is a twitter application that uses a UIPickerview to display options. I have not been able to get anything to show up on the UIPickerview.

my InstatwitViewController.h looks like:

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

and my InstaTwitViewController.m looks like:

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

and ....

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

and....

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

i went into IB and right-clicked on the picker and dragged the dataSource to the files owner, just like the book told me then when i ran it.. i got black screen then nothing.

heres my debugger

[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 PurpleEv开发者_高级运维entCallback + 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) 

any help would be great, because this is for a class, and im a complete noob and i've been stuck here for around a month.

thanks


You are missing a space in the delegate method. Use:

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

精彩评论

暂无评论...
验证码 换一张
取 消