I have to use NSMutableSet
to store my string objects. I wan to store them in right order for example from smallest to biggest number:
1
2
3
4
How ever if do this:
NSMutableSet *set = [[NSMutableSet alloc] init];
[set addObject:[NSString stringWithFormat:@"1"]];
[set addObject:[NSString stringWithFormat:@"2"]];
[set addObject:[NSString stringWithFormat:@"3"]];
[set addObject:[NSString stringWithFormat:@"4"]];
NSLog(@"set is %@",set);
[set release];
I don't get what i wanted but instead this:
set is {(
3,
1,
4,
2
)}
So I guess i need to sort them to get wanted result ? But really i can't find any example.
Maybe someone could help me on this ?
Thanks.
EDIT:
I can't use else. Just NSMutableSet
or NSSet
If there's any characteristic of the NSSet is that they dont have any order!
You should use a NSMutableArray for your purpose.
Read about collections here, it will help you