Error when running initially


#1

I’m up to the initial build on page 203. I’ve rebuilt the project 3 times now and am getting the same error. The project successfully builds. When I hit the ‘Insert’ button I get the following error:

my code is as follows:

[code]//
// BNRDocument.h
// TahDoodle
//

//

#import <Cocoa/Cocoa.h>

@interface BNRDocument : NSDocument
{
NSMutableArray *todoItems;
IBOutlet NSTableView *itemTableView;
}

-(IBAction)createNewItem:(id)sender;

@end
[/code]

and

[code]//
// BNRDocument.m
// TahDoodle
//

//

#import “BNRDocument.h”

@implementation BNRDocument

#pragma mark - NSDocument Overrides

-(IBAction)createNewItem:(id)sender
{
//if no array, make a new one
if (!todoItems){
todoItems = [NSMutableArray array];
}

[todoItems addObject:@"New Item"];

//reloadData tells tableview to refresh and ask dataSource for new data to display
[itemTableView reloadData];

//updateChangeCount tell app if doc has unsaved changes
[self updateChangeCount:NSChangeDone];

}

#pragma mark Data Source Methods

-(NSInteger)numberOfRowsInTableView:(NSTableView *)tv
{
return [todoItems count];
}

-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
return [todoItems objectAtIndex:row];
}

-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
[todoItems replaceObjectAtIndex:row withObject:object];
[self updateChangeCount:NSChangeDone];
}

  • (id)init
    {
    self = [super init];
    if (self) {
    // Add your subclass-specific initialization here.
    // If an error occurs here, return nil.
    }
    return self;
    }

  • (NSString *)windowNibName
    {
    // Override returning the nib file name of the document
    // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
    return @“BNRDocument”;
    }

  • (void)windowControllerDidLoadNib:(NSWindowController *)aController
    {
    [super windowControllerDidLoadNib:aController];
    // Add any code here that needs to be executed once the windowController has loaded the document’s window.
    }

  • (NSData *)dataOfType:(NSString *)typeName error:(NSError *)outError
    {
    /

    Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil.
    You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
    */
    NSException *exception = [NSException exceptionWithName:@“UnimplementedMethod” reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)] userInfo:nil];
    @throw exception;
    return nil;
    }

  • (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError *)outError
    {
    /

    Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO.
    You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
    */
    NSException *exception = [NSException exceptionWithName:@“UnimplementedMethod” reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)] userInfo:nil];
    @throw exception;
    return YES;
    }

@end
[/code]


#2

When you originally created the project did you check the “Enable ARC” box?


#3

When I navigate Edit>Refactor> “Convert to Objective-C ARC” is greyed out, which would suggest ARC is already enabled, right?


#4

I’m getting the exact same error. Any updates? Ideas?

*nvm
found the solution here
viewtopic.php?f=160&t=3696