I have the following code:
self.temporaryImageArray = [(NSSet *)[[array objectAtIndex:0] images] allObjects]
Array holds an Band
object from my CoreData model. It has an NSSet
as a property called "images".
Now I use this temporaryImageArray
to determine via timestamps whether or not the images need to be updated. I have come across some very random behavior and my question now is:
Does [NSSet allObjects]
return the Objects from the Set randomly in no order?
Is there any way to prevent this or to have it return it in order? It would lessen the complexity of my code a lot.
NSSet
is an unordered collection. It has no idea what the "order" of its objects are. Therefore, when you call -allObjects
, it returns them unordered.
Note that the documentation on -allObjects
states:
An array containing the set’s members, or an empty array if the set has no members. The order of the objects in the array isn’t defined.
(emphasis mine)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With