Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
I have asked this question before and was pointed towards google to read up on hash values. I kind of got lost so started looking at alternatives. I am parsing an XML feed and storing the Values on the documents attributes into Strings and then into an NSMutableArray. Some node values are duplicated and also added to array. When I put the data Into a UITableView I only want to show one occurrence of the string. Example
Table shows abc abc def abc
And I only want it to show abc def
I am thinking of instead of added the values to an array I will add to an NSMutableSet and then add the contents of the set to an array as a set can only contain one istance of a particular string. And the use the NSsortDescriptor to arrange the date into an order.
Is this approach possible or should I look more at the hash option suggested previously?
Your approach sounds fine. There is also NSOrderedSet, which, according to the documentation (https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSOrderedSet_Class/Reference/Reference.html), "You can use ordered sets as an alternative to arrays when the order of elements is important and performance in testing whether an object is contained in the set is a consideration testing for membership of an array is slower than testing for membership of a set."
However, performance is not likely to be an issue for you unless you are dealing with a massive amount of data (hundred thousands or millions of rows).
Your approach sounds fine. There is also NSOrderedSet, which, according to the documentation (https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSOrderedSet_Class/Reference/Reference.html), "You can use ordered sets as an alternative to arrays when the order of elements is important and performance in testing whether an object is contained in the set is a consideration testing for membership of an array is slower than testing for membership of a set."
However, performance is not likely to be an issue for you unless you are dealing with a massive amount of data (hundred thousands or millions of rows).
Well no it's not that big. The order the items a added a not that important as I parse through the document the values are in not particular order anyway. I just use the NSsortDescriptor to order them for display in a table kinda alphabetical for user benefit. Thanks for your link too I'll have another read up
Well no it's not that big. The order the items a added a not that important as I parse through the document the values are in not particular order anyway. I just use the NSsortDescriptor to order them for display in a table kinda alphabetical for user benefit. Thanks for your link too I'll have another read up
Indeed, as FStuff says, it sounds like an NSOrderedSet (or NSMutableOrderedSet, if you need it to be mutable) is what you need. That will give you both item uniqueness, like a set, and ordering, like an array. Plus as a side benefit, testing for membership is faster.
NSMutableOrderedSet has several sorting methods like sortUsingComparator: that let you sort the set. All the sort methods have the substring "usingComparator" in their names.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
Replies
However, performance is not likely to be an issue for you unless you are dealing with a massive amount of data (hundred thousands or millions of rows).
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeNSMutableOrderedSet has several sorting methods like sortUsingComparator: that let you sort the set. All the sort methods have the substring "usingComparator" in their names.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome