尝试在标签栏应用程序中使用表视图时,iPhone应用程序崩溃时会发出NSException

时间:2012-05-31 19:19:11

标签: iphone tableview tabbar

我正在尝试在标签栏应用程序中实现表视图,但是当我尝试单击该标签栏项时,应用程序崩溃时会出现NSException。 这是控制台中的例外:

由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是密钥委托的密钥值编码兼容。'

* 首次调用堆栈:

(     0 CoreFoundation 0x00f575a9 __exceptionPreprocess + 185

1   libobjc.A.dylib                     0x010ab313 objc_exception_throw + 44
2   CoreFoundation                      0x00f574e1 -[NSException raise] + 17
3   Foundation                          0x00031677 _NSSetUsingKeyValueSetter + 135
4   Foundation                          0x000315e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5   UIKit                               0x002ecff6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
6   UIKit                               0x004b530c -[UIRuntimeOutletConnection connect] + 112
7   CoreFoundation                      0x00ecd8cf -[NSArray makeObjectsPerformSelector:] + 239
8   UIKit                               0x004b3d23 -[UINib instantiateWithOwner:options:] + 1041
9   UIKit                               0x004b5ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
10  UIKit                               0x0036b628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
11  UIKit                               0x00369134 -[UIViewController loadView] + 120
12  UIKit                               0x0036900e -[UIViewController view] + 56
13  UIKit                               0x0037bf54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
14  UIKit                               0x0037aaaa -[UITabBarController transitionFromViewController:toViewController:] + 64
15  UIKit                               0x0037c8a2 -[UITabBarController _setSelectedViewController:] + 263
16  UIKit                               0x0037c711 -[UITabBarController _tabBarItemClicked:] + 352
17  UIKit                               0x002b94fd -[UIApplication sendAction:to:from:forEvent:] + 119
18  UIKit                               0x004bbce6 -[UITabBar _sendAction:withEvent:] + 422
19  UIKit                               0x002b94fd -[UIApplication sendAction:to:from:forEvent:] + 119
20  UIKit                               0x00349799 -[UIControl sendAction:to:forEvent:] + 67
21  UIKit                               0x0034bc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
22  UIKit                               0x00349750 -[UIControl sendActionsForControlEvents:] + 49
23  UIKit                               0x002b94fd -[UIApplication sendAction:to:from:forEvent:] + 119
24  UIKit                               0x00349799 -[UIControl sendAction:to:forEvent:] + 67
25  UIKit                               0x0034bc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
26  UIKit                               0x0034a7d8 -[UIControl touchesEnded:withEvent:] + 458
27  UIKit                               0x002ddded -[UIWindow _sendTouchesForEvent:] + 567
28  UIKit                               0x002bec37 -[UIApplication sendEvent:] + 447
29  UIKit                               0x002c3f2e _UIApplicationHandleEvent + 7576
30  GraphicsServices                    0x018af992 PurpleEventCallback + 1550
31  CoreFoundation                      0x00f38944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
32  CoreFoundation                      0x00e98cf7 __CFRunLoopDoSource1 + 215
33  CoreFoundation                      0x00e95f83 __CFRunLoopRun + 979
34  CoreFoundation                      0x00e95840 CFRunLoopRunSpecific + 208
35  CoreFoundation                      0x00e95761 CFRunLoopRunInMode + 97
36  GraphicsServices                    0x018ae1c4 GSEventRunModal + 217
37  GraphicsServices                    0x018ae289 GSEventRun + 115
38  UIKit                               0x002c7c93 UIApplicationMain + 1160
39  LTER1                               0x0000216c main + 102
40  LTER1                               0x000020fd start + 53

) 抛出'NSException'实例后调用终止

这是我的代码:

    #import "personnelView.h"


@implementation personnelView


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return exercises.count;
}



- (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"];
    }
    //fill it with contents
    cell.textLabel.text = [exercises objectAtIndex:indexpath.row];

    //return it
    return cell;

}
// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.


 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {

     //load from plist
     NSString *myfile = [[NSBundle mainBundle]
                         pathForResource:@"exercise" ofType:@"plist"];
     exercises = [[NSArray alloc] initWithContentsOfFile:myfile];

     [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 {
    //[super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


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


@end

任何人都可以让我知道我做错了吗?

0 个答案:

没有答案