PopKernel
PopKernel

Reputation: 4260

Property/method not found?

I'm trying to call a method from the Document class, as well as a method of an object that Document has a pointer to. I suspect I'm making some basic mistake; here's are the relevant portions of what I wrote:

Document.h:

@interface Document : NSDocument
<NSTableViewDataSource>

@property (weak) IBOutlet NSTableView *listTable;
@property (nonatomic) NSMutableArray *items;

MyTableviewDataSource.m:

- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
  forTableColumn:(NSTableColumn *)aTableColumn
          row:(NSInteger)rowIndex;
{
[Document.items replaceObjectAtIndex:rowIndex withObject:anObject];

}

Xcode highlights that last message send in MyTableViewDataSource and gives the error:

Property 'items' not found on object of type 'Document'

Sorry if this question is confusing, I am new to coding and am struggling to articulate the stuff I've learned in words. Thanks in advance!

Upvotes: 0

Views: 91

Answers (1)

CRD
CRD

Reputation: 53000

The line:

[Document.items replaceObjectAtIndex:rowIndex withObject:anObject];

is trying to call items on the class Document - you need an instance of Document. Somewhere you must create a Document instance and that is what your method needs to reference.

Upvotes: 2

Related Questions