class OSX::NSObject def objectsForEntityNamed(ename) ed=NSEntityDescription.entityForName(ename,inManagedObjectContext:self) fr=NSFetchRequest.alloc.init fr.setEntity(ed) self.executeFetchRequest(fr,error:nil) end def objectWithValue_forKey_entityNamed(value,key,entityname) ed=NSEntityDescription.entityForName(ename,inManagedObjectContext:self) fr=NSFetchRequest.alloc.init fr.setEntity(ed) pr=NSPredicate.predicateWithFormat("#{key}==#{value}") fr.setPredicate(pr) self.executeFetchRequest(fr,error:nil) end # objc_method :objectsForEntityNamed, %w{id} def objectWithQuotedValue(value,forKey:key,entityNamed:entityname) ed=NSEntityDescription.entityForName(ename,inManagedObjectContext:self) fr=NSFetchRequest.alloc.init fr.setEntity(ed) pr=NSPredicate.predicateWithFormat("#{key}=='#{value}'") fr.setPredicate(pr) self.executeFetchRequest(fr,error:nil) end end