how does EOs are compared?
how does EOs are compared?
- Subject: how does EOs are compared?
- From: Ricardo Strausz <email@hidden>
- Date: Fri, 5 Sep 2003 16:56:22 -0500
Hola
context:
I am extracting data from an entity to create new objects in another
entity; the user select some objects in a displayGroup, pushes a
button, and all ---not previously inserted--- objects have to be added
in the other displayGroup.
problem:
The code below, inserts ALL of the selected objects; it is failing to
determine if an object was inserted. Since I am using NSSets to try to
avoid duplicity, I am comparing with isEqual:
It does not works...
questions:
How shall I do it?
Any experience with this?
Dino
http://homepage.mac.com/strausz
- (IBAction)add:(id)sender
{
NSDisplayGroup* dgDetallesP; // this exists in the nib; it is my
source of EOs
NSDisplayGroup* dgDetallesF; // this exists in the nib; its class
is: BADetInvoice
NSArray* source = [dgDetallesP selectedObjects];
NSEnumerator* enSource = [source objectEnumerator];
EOGenericRecord* eo = nil;
NSMutableArray* cocoKeys = [NSMutableArray array];
[cocoKeys addObject:@"cantidad"];
[cocoKeys addObject:@"descripcion"];
id util = [[NSClassFromString(@"Util") new] autorelease]; // to do
the Java job
id keys = [util arrayWithArray:cocoKeys]; // this is a
WOMutableArray with the apropiate keys
NSMutableSet* inserted =
[[NSClassFromString(@"com.webobjects.foundation.NSMutableSet") new]
autorelease];
id arDet = [dgDetallesF allObjects];
[inserted addObjectsFromArray:arDet]; // these are the previously
inserted EOs
while([enSource hasMoreElements]){
eo = [enSource nextElement];
NSDictionary* nsd = [eo valuesForKeys:keys];
EOGenericRecord* neo = [[NSClassFromString(@"BADetInvoice")
new] autorelease]; // a new EO to be inserted...
[neo takeValuesFromDictionary:nsd]; // ... which takes values
from another existing EO (in other entity), but...
if(![inserted containsObject:neo]){ // ... I do not want to
duplicate EOs !!!!!
[ec insertObject:neo];
[dgDetallesF insertObjectAtIndex:neo :0];
[dgDetallesF redisplay];
}
}
}
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.