Objective c 西格巴特错误:';NSInvalidArgumentException';

Objective c 西格巴特错误:';NSInvalidArgumentException';,objective-c,ios,runtime-error,Objective C,Ios,Runtime Error,在过去的一天里,我刚刚破坏了我的rootViewController。我现在得到这个错误,我不知道在哪里可以修复它 任何关于如何修复的帮助,甚至更好的帮助,都可以帮助我破译错误输出,这样我就可以自己做了 2011-10-24 08:56:29.746 DiningLog[2955:207] -[NSCFString setTableViewStyle:]: unrecognized selector sent to instance 0x595b150 2011-10-24 08:56:29.7

在过去的一天里,我刚刚破坏了我的rootViewController。我现在得到这个错误,我不知道在哪里可以修复它

任何关于如何修复的帮助,甚至更好的帮助,都可以帮助我破译错误输出,这样我就可以自己做了

2011-10-24 08:56:29.746 DiningLog[2955:207] -[NSCFString setTableViewStyle:]: unrecognized selector sent to instance 0x595b150
2011-10-24 08:56:29.749 DiningLog[2955:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString setTableViewStyle:]: unrecognized selector sent to instance 0x595b150'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00fa25a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x010f6313 objc_exception_throw + 44
    2   CoreFoundation                      0x00fa40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00f13966 ___forwarding___ + 966
    4   CoreFoundation                      0x00f13522 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x00330bd5 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 695
    6   UIKit                               0x003264cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
    7   UIKit                               0x0033b8cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
    8   UIKit                               0x0033390c -[UITableView layoutSubviews] + 242
    9   QuartzCore                          0x01f42a5a -[CALayer layoutSublayers] + 181
    10  QuartzCore                          0x01f44ddc CALayerLayoutIfNeeded + 220
    11  QuartzCore                          0x01eea0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
    12  QuartzCore                          0x01eeb294 _ZN2CA11Transaction6commitEv + 292
    13  UIKit                               0x002bd9c9 -[UIApplication _reportAppLaunchFinished] + 39
    14  UIKit                               0x002bde83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
    15  UIKit                               0x002c8617 -[UIApplication handleEvent:withNewEvent:] + 1533
    16  UIKit                               0x002c0abf -[UIApplication sendEvent:] + 71
    17  UIKit                               0x002c5f2e _UIApplicationHandleEvent + 7576
    18  GraphicsServices                    0x018fa992 PurpleEventCallback + 1550
    19  CoreFoundation                      0x00f83944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    20  CoreFoundation                      0x00ee3cf7 __CFRunLoopDoSource1 + 215
    21  CoreFoundation                      0x00ee0f83 __CFRunLoopRun + 979
    22  CoreFoundation                      0x00ee0840 CFRunLoopRunSpecific + 208
    23  CoreFoundation                      0x00ee0761 CFRunLoopRunInMode + 97
    24  UIKit                               0x002bd7d2 -[UIApplication _run] + 623
    25  UIKit                               0x002c9c93 UIApplicationMain + 1160
    26  DiningLog                           0x0000213c main + 102
    27  DiningLog                           0x000020cd start + 53
)
terminate called after throwing an instance of 'NSException'
Current language:  auto; currently objective-c
(gdb) 
以下是请求代码:

//
//  RootViewController.m
//  DiningLog
//
//  Created by Eric Rea on 3/3/11.
//  Copyright 2011 Avid. All rights reserved.
//

#import "RootViewController.h"
#import "ModalView.h"

@interface RootViewController ()
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
@end


@implementation RootViewController

@synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_;
@synthesize plistArray, excersizeArray;


#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
    [super viewDidLoad];

    // Set up the edit and add buttons.
    self.navigationItem.leftBarButtonItem = self.editButtonItem;

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
    self.navigationItem.rightBarButtonItem = addButton;
    [addButton release];

    // get paths from root direcory
    NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
    // get documents path
    NSString *documentsPath = [paths objectAtIndex:0];
    // get the path to our Data/plist file
    NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"ExcersizeList.plist"];

    // check to see if Data.plist exists in documents
    if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath])
    {
        // if not in documents, get property list from main bundle
        plistPath = [[NSBundle mainBundle] pathForResource:@"Excersizes" ofType:@"plist"];
    }

    // read property list into memory as an NSData object
    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
    NSString *errorDesc = nil;
    NSPropertyListFormat format;
    // convert static property list into dictionary object
    NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
    if (!temp)
    {
        NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
    }
    // assign values
    self.plistArray = [NSMutableArray arrayWithArray:[temp objectForKey:@"Excersizes"]];

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.plistArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    /* create your cell here */

    excersizeArray = [self.plistArray objectAtIndex:[indexPath row]];

                                       /* fill the cell with the info in my object */

    return [excersizeArray objectAtIndex:(NSUInteger)0];
                                       }


// Implement viewWillAppear: to do additional setup before the view is presented.
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}


/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
*/

/*
 // Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
 */


- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {

    NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
    cell.textLabel.text = [[managedObject valueForKey:@"Excersizes"] description];
}


#pragma mark -
#pragma mark Add a new object

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {

    // Prevent new objects being added when in editing mode.
    [super setEditing:(BOOL)editing animated:(BOOL)animated];
    self.navigationItem.rightBarButtonItem.enabled = !editing;
}


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 20;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the managed object for the given index path
        NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
        [context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];

        // Save the context.
        NSError *error = nil;
        if (![context save:&error]) {
            /*
             Replace this implementation with code to handle the error appropriately.

             abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
             */
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
            abort();
        }
    }   
}


- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // The table view should not be re-orderable.
    return NO;
}


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here -- for example, create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */
}


#pragma mark -
#pragma mark Fetched results controller

- (NSFetchedResultsController *)fetchedResultsController {

    if (fetchedResultsController_ != nil) {
        return fetchedResultsController_;
    }

    /*
     Set up the fetched results controller.
    */
    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    // Set the batch size to a suitable number.
    [fetchRequest setFetchBatchSize:20];

    // Edit the sort key as appropriate.
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Excersizes" ascending:NO];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means "no sections".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;

    [aFetchedResultsController release];
    [fetchRequest release];
    [sortDescriptor release];
    [sortDescriptors release];

    NSError *error = nil;
    if (![fetchedResultsController_ performFetch:&error]) {
        /*
         Replace this implementation with code to handle the error appropriately.

         abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
         */
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    return fetchedResultsController_;
}    


#pragma mark -
#pragma mark Fetched results controller delegate


- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
    [self.tableView beginUpdates];
}


- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {

    switch(type) {
        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}


- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath {

    UITableView *tableView = self.tableView;

    switch(type) {

        case NSFetchedResultsChangeInsert:
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeUpdate:
            [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}


- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    [self.tableView endUpdates];
}


/*
// Implementing the above methods to update the table view in response to individual changes may have performance implications if a large number of changes are made simultaneously. If this proves to be an issue, you can instead just implement controllerDidChangeContent: which notifies the delegate that all section and object changes have been processed. 

 - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    // In the simplest, most efficient, case, reload the table view.
    [self.tableView reloadData];
}
 */


#pragma mark -
#pragma mark Memory management

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

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


- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [fetchedResultsController_ release];
    [managedObjectContext_ release];
    [super dealloc];
}


@end
//
//RootViewController.m
//迪宁日志
//
//由Eric Rea于2011年3月3日创建。
//版权所有2011 Avid。版权所有。
//
#导入“RootViewController.h”
#导入“ModalView.h”
@接口RootViewController()
-(void)configureCell:(UITableViewCell*)单元格atIndexPath:(NSIndexPath*)indexPath;
@结束
@RootViewController的实现
@综合fetchedResultsController=fetchedResultsController,managedObjectContext=managedObjectContext;
@合成普利斯塔雷、施瓦西阵列;
#布拉格标记-
#pragma标记视图生命周期
-(无效)viewDidLoad{
[超级视图下载];
//设置编辑和添加按钮。
self.navigationItem.leftBarButtonItem=self.editButtonItem;
UIBarButtonItem*addButton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAddTarget:self action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem=addButton;
[添加按钮释放];
//从根目录获取路径
NSArray*Path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,是);
//获取文档路径
NSString*documentsPath=[path objectAtIndex:0];
//获取数据/plist文件的路径
NSString*plistPath=[documentsPath stringByAppendingPathComponent:@“exercizelist.plist”];
//检查文档中是否存在Data.plist
如果(![[NSFileManager defaultManager]文件存在路径:plistPath])
{
//如果不在文档中,则从主捆绑包获取属性列表
plistPath=[[NSBundle mainBundle]pathForResource:@“exercises”类型:@“plist”];
}
//将属性列表作为NSData对象读入内存
NSData*plistXML=[[NSFileManager defaultManager]contentsAtPath:plistPath];
NSString*errorDesc=nil;
NSPropertyListFormat格式;
//将静态属性列表转换为字典对象
NSDictionary*temp=(NSDictionary*)[NSPropertyListSerialization propertyListFromData:plistXML可变选项:NSPropertyListMutableContainers和Leaves格式:&格式错误描述:&错误描述];
如果(!temp)
{
NSLog(@“错误读取plist:%@,格式:%d”,错误描述,格式);
}
//赋值
self.plistArray=[NSMutableArray arrayWithArray:[temp objectForKey:@“Excersizes”];
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节{
返回[self.plistaray count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
/*在这里创建您的单元格*/
excersizeArray=[self.plistArray objectAtIndex:[indexPath行]];
/*用“我的对象”中的信息填充单元格*/
返回[excersizeArray objectAtIndex:(NSInteger)0];
}
//机具视图将显示:在显示视图之前执行其他设置。
-(无效)视图将显示:(BOOL)动画{
[超级视图将显示:动画];
}
/*
-(无效)视图显示:(BOOL)动画{
[超级视图显示:动画];
}
*/
/*
-(无效)视图将消失:(BOOL)已设置动画{
[超级视图将消失:动画];
}
*/
/*
-(无效)视图消失:(BOOL)已设置动画{
[超级视窗消失:动画];
}
*/
/*
//替代以允许默认纵向方向以外的方向。
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
//对于支持的方向,返回YES。
返回(interfaceOrientation==UIInterfaceOrientationGraphic);
}
*/
-(void)configureCell:(UITableViewCell*)单元格atIndexPath:(NSIndexPath*)indexPath{
NSManagedObject*managedObject=[self.fetchedResultsController对象索引路径:indexPath];
cell.textlab.text=[[managedObject valueForKey:@“Excersizes”]说明];
}
#布拉格标记-
#pragma标记添加新对象
-(void)设置编辑:(BOOL)编辑动画:(BOOL)动画{
//防止在编辑模式下添加新对象。
[超级设置编辑:(BOOL)编辑动画:(BOOL)动画];
self.navigationItem.rightBarButtonItem.enabled=!编辑;
}
#布拉格标记-
#pragma标记表视图数据源
-(NSInteger)表格视图中的节数:(UITableView*)表格视图{
返回20;
}
/*
//替代以支持表视图的条件编辑。
-(BOOL)tableView:(UITableView*)tableView caneditrowatinexpath:(nsindepath*)indepath{
//如果不希望指定的项可编辑,则返回“否”。
返回YES;
}
*/
//替代以支持编辑表格视图。
-(void)tableView:(UITableView*)tableView提交的编辑样式:(UITableViewCellEditingStyle)行的编辑样式索引路径:(NSIndexPath*)索引路径{
如果(editingStyle==UITableViewCellEditingStyleDelete){
//删除给定索引路径的托管对象
NSManagedObjectContext*上下文=[self.fetchedResultsController managedObjectContext];
[上下文删除对象:[self.fetchedResultsController对象索引路径:indexPath]];
//保存上下文。
n错误*错误=nil;
如果(![上下文保存:&错误]){
/*
将此实现替换为适当处理错误的代码。
abort()导致应用程序生成崩溃日志并终止。您不应在装运应用程序中使用此函数,尽管它在开发过程中可能很有用。如果无法从错误中恢复,请显示一个警告面板,指示用户通过按“主页”按钮退出应用程序。
*/
NSLog(@“未解决的错误%@,%@”,错误,[error userInfo]);
中止();
}
}   
}
-(BOOL)tableView:(UITableView*)tableV
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
cell.text = @"Value";

return cell;
}