NSMutableArray result = new NSMutableArray(); if (eos.count() > 0) { String entityName = ((EOEnterpriseObject) eos.objectAtIndex(0)).entityName(); EOEditingContext ec = ((EOEnterpriseObject) eos.objectAtIndex(0)).editingContext(); EOEntity entity = EOUtilities.entityNamed(ec, entityName); EORelationship relationship = entity.relationshipNamed(relKey); EOAttribute attribute = (EOAttribute) relationship.sourceAttributes().objectAtIndex(0); EODatabaseContext context = EOUtilities.databaseContextForModelNamed(ec, entity.model().name()); String name = attribute.name(); for (Enumeration e = eos.objectEnumerator(); e.hasMoreElements();) { EOEnterpriseObject target = (EOEnterpriseObject) e.nextElement(); Object value = (context.snapshotForGlobalID(ec.globalIDForObject(target))).valueForKey(name); result.addObject(value); } } return result;
NSMutableArray result = new NSMutableArray(); if (eos.count() > 0) { EOEnterpriseObject eo = (EOEnterpriseObject)eos.lastObject(); String entityName = eo.entityName(); EOEditingContext ec = eo.editingContext(); EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName); EORelationship relationship = entity.relationshipNamed(relKey); if(relationship.sourceAttributes().count() == 1) { EOAttribute attribute = (EOAttribute) relationship.sourceAttributes().lastObject(); EODatabaseContext context = EOUtilities.databaseContextForModelNamed(ec, entity.model().name()); String name = attribute.name(); for (Enumeration e = eos.objectEnumerator(); e.hasMoreElements();) { EOEnterpriseObject target = (EOEnterpriseObject) e.nextElement(); Object value = (context.snapshotForGlobalID(ec.globalIDForObject(target))).valueForKey(name); result.addObject(value); } } else { throw new IllegalArgumentException("Has more than one relationship attribute: " + relKey); } } return result;
    public static NSArray snapshotsForObjectsFromRelationshipNamed(NSArray eos, String relKey) {        NSMutableArray result = new NSMutableArray();        if (eos.count() > 0) {            String entityName = ((EOEnterpriseObject) eos.objectAtIndex(0)).entityName();            EOEditingContext ec = ((EOEnterpriseObject) eos.objectAtIndex(0)).editingContext();            EOEntity entity = EOUtilities.entityNamed(ec, entityName);            EORelationship relationship = entity.relationshipNamed(relKey);            EOAttribute attribute = (EOAttribute) relationship.sourceAttributes().objectAtIndex(0);            EODatabaseContext context = EOUtilities.databaseContextForModelNamed(ec, entity.model().name());            String name = attribute.name();            for (Enumeration e = eos.objectEnumerator(); e.hasMoreElements();) {                EOEnterpriseObject target = (EOEnterpriseObject) e.nextElement();                Object value = (context.snapshotForGlobalID(ec.globalIDForObject(target))).valueForKey(name);                result.addObject(value);            }        }        return result;    }