Hello,

I have a trouble with my non-document-based Core Data application and
hope some advice.

My app has a "Transaction" entity and it has a mainTransaction and a subTransactions
relationships which are set inverse each other.

mainTransaction to subTransactions is a to-many relationship, while
subTransactions to mainTransaction is a to-one relationship.

I have a method to create a main transaction and sub-transactions
like below.

- (void) createAndSetMainTransaction: (NSArray *) myDataArray // array of myData
{
MyDataType * myData; // contains transaction attribute data to be filled in transactionMO NSManagedObject * firstTransactionMO = nil; // a transactionMO which will be created first

        for ( myData in myDataArray )
        {
NSManagedObject * transactionMO = [self createATransactionMOAndFillMyData: myData];

                if ( firstTransactionMO == nil )
                {
                        firstTransactionMO = transactionMO;
                }
                else
                {
[transactionMO setValue: firstTransactionMO forKey: @"mainTransaction"]; // problematic line // setting the first transactionMO as the mainTransaction for all the
                        // rest of the transactionMOs created within this method
                }
        }
}

-----

This method works and transactions created here are displayed in an NSTableView
through NSArrayController and Cocoa Bindings, exactly as I expected.

But once I save the data to a file (with NSSQLiteStoreType) and start the app again, the app crashes when the app tries to display the data in the NSTableView.

If I commented out the "problematic line", the app doesn't crash and everything
seems fine except the subTransactions don't have the mainTransaction.

I don't figure out what is wrong with the problematic line and hope some
advice to fix this problem.

Thank you.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to