Creating Inverse Master Data Relationships

I'm trying to write my first Cocoa application, and Core Data makes it difficult to model my data objects. I have two objects that I want to manipulate: Accountand Transaction. Accounthas a human-readable name about it. Transactionstores a monetary value and links to two accounts called debitAccountand creditAccount(I'm working on an application for accounting in two books).

I want to find everything Transactionsfor a given Accountwhether they use debitAccountor creditAccount. How can i do this? Is there a way to do this that will work easily with Cocoa UI binding?

+3
source share
2 answers

, ( ), NSManagedObject Account:

@interface Account : NSManagedObject {

}
-(NSArray*)getTransactions;
@end

-getTransactions, . , , KVO.

Core Data Account NSManagedObject s, "Class" Xcode.

0

, , : debitAccount creditAccount, ? .

, . , , , , transactions, debitAccount, creditAccount. , debitTransactions creditTransactions ( , ...)

, ( , NSSet s), creditTransactions debitTransactions , , .

A (, ) TransactionAccount, " " Account, Transaction, , accountRole . - Transaction, Account , transactionAccounts. , :

[account valueForKeyPath:@"transactionAccounts.transaction"]

. NSPredicate , / .

+4

Source: https://habr.com/ru/post/1704526/


All Articles