0

我正在开发一个具有书籍对象(RSEBook)的应用程序,每个对象都有一个关键字对象(关键字)的 NSMutableArray。书中的可变数组称为“关键字”

将子项(关键字)添加到父项数组的方法是:

-(void)addTag:(关键字 *)word {

[关键字 addObject:word];

[字集父母:自我];

}

然而,当它在 Document.m 中被调用时:

-(IBAction)createKeyword:(id)sender{

NSWindow *w = [tabView 窗口];

BOOL editingEnded = [w makeFirstResponder:w];
if(!editingEnded) {
    NSBeep();
    return;
}

Keyword *k = [[Keyword alloc] init];  //Create a new keyword instance

id current = [booksAC selectedObjects]; //NSArray of the selectedObjects (there will only ever be one object in the array as my table view hasn't got multi selection

RSEBook *currBook = [current objectAtIndex:0]; //Get that object into currBook

if (!currBook) {                              //Check that currBook = something
    NSLog(@"current is nil");
}
[currBook addTag:k];             //Add the object k as a tag to currBooks NSMutableArray 'keywords' this SHOULD set the parent, but it dosent (defined in RSEBook.h)


NSLog(@"The keywords parent: %@" ,[k parent]);  // this is always null for some reason
NSLog(@"parents keywords: %@", [currBook keywords]);  // this returns what I expect, a list of the books keywords
4

0 回答 0