2014-01-09 49 views
0

我試圖從Document類調用一個方法,以及Document有一個指針的對象的方法。我懷疑我犯了一些基本的錯誤;這裏的是我寫的有關部分:搜索房源/方法?

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中強調了最後一條消息在MyTableViewDataSource發送,並給出了錯誤:

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

對不起,如果這個問題很混亂,我是新來的科迪並且正在努力闡明我用言語學到的東西。 在此先感謝!

+0

該屬性尚未在Document.m文件中合成 - 或在頁眉中自動合成。 – Luke

回答

2

行:

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

試圖調用itemsDocument - 你需要一個實例Document。某處您必須創建一個Document實例,這就是您的方法需要引用的內容。

+0

感謝您的幫助。我知道這是愚蠢的。 – PopKernel