I have a question in core data:
there are 2 Entities in the project, Books
and Pages
;
there are 3 Objects book
s user created in Entity Books
;
there are several Objects page
s user created in Entity Pages
;
relationship inbetween is one page
belongs to one book
, one book
has many pages.
and my question: there are 3 book
with the same object name "book",and each has unique attribute .bookName
: @"metal"
;@"plastic"
;@"glass"
. how to set page
to the book
with .bookName = @"glass"
?
//In BookViewController
Books *book = (Books *)[NSEntityDescription insertNewObjectForEntityForName:@"Books" inManagedObjectContext:managedObjectContext];
//textView.text is user input text
book.bookName = textView.text;
//In PageViewController
Pages *page = (Pages *)[NSEntityDescription insertNewObjectForEntityForName:@"Pages" inManagedObjectContext:managedObjectContext];
page.itsbook = WHAT?
Thank you for reading, I stuck here like: a day, really appreciate your help, love you!