FROM : Marcus S. Zarra
DATE : Fri May 04 18:45:28 2007
On 5/4/07, Hell's KItchen Hell's KItchen <<email_removed>> wrote:
> a) is possible to set the value of an attribute with a predicate? For
> example I would to set the 'label' attribute to 1 for all entities
> into the managed objects. Is the only way to get the complete array of
> these entities and then apply the attribute to each manually"?
No, but you can retrieve them into an array and then call
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject
on the array. This avoids having to loop over the array and call the
method on each object individually.
> b) is possible to get the number of items given from a predicate
> results instead of using [resultsArray count]? (a sort of count(*) for
> sql, I don't need of the list). Or there is not any issue on general
> performances? This action will be repeated lots of time in my app.
Again no. Fortunately when the array is retrieved all of the objects
are "faults" which means they are not loaded into memory yet and your
call to count will not cause them to load. Therefore the memory and
performance hits are negligible.
Marcus S. Zarra
Zarra Studios LLC
Simply Elegant Software for OS X
www.zarrastudios.com
DATE : Fri May 04 18:45:28 2007
On 5/4/07, Hell's KItchen Hell's KItchen <<email_removed>> wrote:
> a) is possible to set the value of an attribute with a predicate? For
> example I would to set the 'label' attribute to 1 for all entities
> into the managed objects. Is the only way to get the complete array of
> these entities and then apply the attribute to each manually"?
No, but you can retrieve them into an array and then call
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject
on the array. This avoids having to loop over the array and call the
method on each object individually.
> b) is possible to get the number of items given from a predicate
> results instead of using [resultsArray count]? (a sort of count(*) for
> sql, I don't need of the list). Or there is not any issue on general
> performances? This action will be repeated lots of time in my app.
Again no. Fortunately when the array is retrieved all of the objects
are "faults" which means they are not loaded into memory yet and your
call to count will not cause them to load. Therefore the memory and
performance hits are negligible.
Marcus S. Zarra
Zarra Studios LLC
Simply Elegant Software for OS X
www.zarrastudios.com
| Related mails | Author | Date |
|---|---|---|
| Hell's KItchen Hel… | May 4, 13:25 | |
| Marcus S. Zarra | May 4, 18:45 | |
| Robert Walker | May 4, 18:47 | |
| Robert Walker | May 4, 18:59 | |
| Marcus S. Zarra | May 4, 19:03 | |
| Robert Walker | May 4, 22:04 | |
| Marcus S. Zarra | May 4, 23:08 | |
| Robert Walker | May 4, 23:48 | |
| Steve Israelson | May 5, 00:33 |






Cocoa mail archive

