Re: Removing Object form ArrayController without managedObjectContext
Re: Removing Object form ArrayController without managedObjectContext
- Subject: Re: Removing Object form ArrayController without managedObjectContext
- From: Gustavo Pizano <email@hidden>
- Date: Mon, 29 Mar 2010 23:29:00 +0200
Keary Hi.
On Mar 29, 2010, at 10:22 PM, Keary Suska wrote:
> On Mar 29, 2010, at 1:43 PM, Gustavo Pizano wrote:
>
>> My guess was that when removing the objects form the array controller, these were being removed form the MOC, and therefore I couldn't see them in the consultation mode, only after restarting the app when the MOC fetch again the data.
>
> An array controller won't remove MO's unless you have told it to. Check the setting in IB, or set it explicitly in code.
>
In IB Im not setting the "Delete Objects on Remove" because the only binding it has its the MOC, and second I wouldn't put it if I could becuase I know it will remove them form the MOC,
>> Now I need to be able to clean the table after saving, otherwise I can't create more items unless I restart the app, or if I clean the table I must restart the app in order to see the newly created invoice's details.
>
> This is a sign of poor design. The items array controller should use the invoice relationship as its content and it will take care of itself.
>
I have, Invoice < ->> ItemXInvoice << > Invoice, the Array controller I set up with ItemXInvoice entity, and when I click an add button I do:
Item * newItem = [NSEntityDescription insertNewObjectForEntityForName:@"Item" inManagedObjectContext:[self managedObjectContext]];
ItemXInvoice * newItemXInvoice = [NSEntityDescription insertNewObjectForEntityForName:@"ItemXInvoice" inManagedObjectContext: [self managedObjectContext]];
[newItemXInvoice setValue:newItem forKey:@"toItem"];
[newItem addToInvoiceXItemsObject:newItemXInvoice];
[_itemsArrayController addObject:newItemXInvoice];
if(_newInvoice == nil){
_newInvoice = [NSEntityDescription insertNewObjectForEntityForName:@"Invoice" inManagedObjectContext:[self managedObjectContext]];
}
[_newInvoice addToItemsXInvoiceObject:newItemXInvoice];
So Im creating a ItemXInvoice relate it to an Item and then relate it to the Invoice relationship as you say. Unless I misunderstood your point and the NSArrayController (ItemXInvoice) the Array Content binding shall be set to the instance with keypath: _newInvoice.toItemXInvoice... I dunno its late here in this part of the work, Im just rumble around..
Any thoughts?
Thanks for the reply.
G
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden