Child pages
  • Web Applications-Development-Cocoa EO Applications

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.



Note: these techniques depend on deprecated technologies. Use at your own risk. - Mike Schrag
Hey, they don't even exist on Mac OS X 10.5.  It's dead, Jim. - Pascal Robert

A CocoaEOApplication (formally, in WO 5.2, Cocoa Enterprise Objects Application, but here simply CEO) is a set of objects which allow you to use the Enterprise Objects Framework (EOF) inside Cocoa. Even though the technology is not yet supported by Apple, it had been around since NeXT was independent.


Code Block
- (IBAction)doit:(id)sender{
     [[displayGroup displayedObjects] takeValueForKey:aValue :@"aKey"];

  • in PB (or Xcode) press cmd+r


An Obj-C array:

Code Block
 NSArray* anObjCArray = [NSArray arrayWithObjects:objA, objB, objC, objD, nil];
 NSEnumerator* en = [anObjCArray objectEnumerator];
 id o = nil;

 while(o = [en nextObject]){
   // here your code using o,
   // which will traverse all objects in the array


There are many solutions to this problem. The first one (for those who knows Java and Obj-C) is to have a object in charge of allocating those arrays as neaded:

Code Block
 public arrayFromArray( cocoaArray)
 { woArray =
     int i;
     return woArray;


and then use it in a fetch specification with

Code Block
 id fetchSpecification =
     new] autorelease];
 [fetchSpecification setEntity:@"myEntity"];
 [fetchSpecification setQualifier:qualifier];

On the other hand, if you want to use a date in your qualifier, since NSCalendarDate is not properly translated to NSTimestamp, you have to use again the trick:

Code Block
 public NSTimestamp nsTimestampFromString(String dateString){
    NSTimestampFormatter formatter = new NSTimestampFormatter("%d %m %Y");
    ParsePosition pp = new ParsePosition(0);
    NSTimestamp myNSTimestamp = (NSTimestamp)formatter.parseObject(dateString, pp);
    return myNSTimestamp;

and call this from Obj-C by

Code Block
 NSCalendarDate aCalendarDate; // suppose this exists
 [aCalendarDate setCalendarFormat:@"%d %m %Y"];
 id nsTimestamp = [bridgeTool nsTimestampFromString:[aCalendarDate description]];


It is also possible (at least in WO 5.2.4 running on Tiger) to use
com.webobjects.eointerface.cocoa.EOCocoaUtilities as follows:

Code Block
 id objPath = @"com.webobjects.eointerface.cocoa.EOCocoaUtilities";
 id aDate = [NSCalendarDate date];
 id nsTimestamp = [NSClassFromString(objPath) timestampForGregorianDate:aDate];