Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray instance variable and core data objects




On Mar 4, 2007, at 6:20 AM, Tim McDonald wrote:

Apart from the questions Timothy asked:

The order in which the values are retrieved is important therefore I was attempting to create a NSArray instance variable to store an ordered list of managed objects.

How are you intending to use and store the array?
Is there any attribute on which you could simply sort the input characteristic types?


from source file:
inputCharacteristicTypes = [NSArray arrayWithArray:[[self mutableSetValueForKey:@"inputCharacteristicTypes"] allObjects]];


This is unnecessarily inefficient.
There is no need to create a mutable proxy ('mutableSetValueForKey:') since you don't use it; 'allObjects' returns a new array, so there is no need to create another array using it.


inputCharacteristicTypes = [[self valueForKey:@"inputCharacteristicTypes"] allObjects];

Perhaps you meant:

inputCharacteristicTypes = [NSMutableArray arrayWithArray:[[self valueForKey:@"inputCharacteristicTypes"] allObjects]];

Note that obviously the order you get objects back from the set is not fixed, so you will have to sort them somehow (see question above).

mmalc


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSArray instance variable and core data objects (From: Tim McDonald <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.