• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
how does EOs are compared?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: how does EOs are compared?
      • From: Art Isbell <email@hidden>
  • Prev by Date: Re: Creating a Table on the DBMS from EOF?
  • Next by Date: Re: Creating a Table on the DBMS from EOF?
  • Previous by thread: Re: Creating a Table on the DBMS from EOF?
  • Next by thread: Re: how does EOs are compared?
  • Index(es):
    • Date
    • Thread