How the Title says - I want to be sure that the object is on the last position but I cant find any functions for NSOrderedSet
. Is it possible to set it simply at data[data.count]
?
How can I add an Object to a NSOrderedSet at the last position?
1.2k Views Asked by Appygix At
3
There are 3 best solutions below
0

NSMutableOrderedSet *mutableData=[data mutableCopy];
[mutableData addObject:theObjectToAdd];
data=mutableData;
0

No. You need to use NSMutableOrderedSet.
In that case, you can just use:
- Swift:
func addObject(_ object: AnyObject)
- Objective-C:
- (void)addObject:(ObjectType)object
NSOrderedSet
is immutable. You'll needNSMutableOrderedSet
, in particular, you'll want to useaddObject(_:)
, such as:NSOrderedSet
andNSMutableOrderedSet
are both a part of the Foundation framework, and do not conform to the CollectionType protocol, so you cannot use the[]
operator like in your question.