nsmutableset

Adding Strings to NsMutableSets

雨燕双飞 提交于 2019-12-27 01:48:29
问题 If I have two string objects that both have value "hi", and I add them to an NSMutableSet, are they treated as different objects or not? Thanks a bunch! 回答1: Beside the correct comment of @rmaddy, there is a fundamental problem with it: It is simply mostly impossible to guarantee that no objects are equal in a set. (It is easy to guarantee that the are not identical.) This would imply to recheck the equaty of all objects (expensive), when one changes (mostly impossible to detect). This is,

Adding Strings to NsMutableSets

徘徊边缘 提交于 2019-12-27 01:48:09
问题 If I have two string objects that both have value "hi", and I add them to an NSMutableSet, are they treated as different objects or not? Thanks a bunch! 回答1: Beside the correct comment of @rmaddy, there is a fundamental problem with it: It is simply mostly impossible to guarantee that no objects are equal in a set. (It is easy to guarantee that the are not identical.) This would imply to recheck the equaty of all objects (expensive), when one changes (mostly impossible to detect). This is,

Adding Strings to NsMutableSets

牧云@^-^@ 提交于 2019-12-27 01:47:08
问题 If I have two string objects that both have value "hi", and I add them to an NSMutableSet, are they treated as different objects or not? Thanks a bunch! 回答1: Beside the correct comment of @rmaddy, there is a fundamental problem with it: It is simply mostly impossible to guarantee that no objects are equal in a set. (It is easy to guarantee that the are not identical.) This would imply to recheck the equaty of all objects (expensive), when one changes (mostly impossible to detect). This is,

Equality of Two NSMutableSets Using Custom Class Attributes

烈酒焚心 提交于 2019-12-25 06:42:20
问题 How do you check if two NSMutableSets are equal ( same members, same number of members )? My implementation of isEqualToSet does not seem to be working. // members is a NSMutableSet of AUser objects // users is also a NSMutableSet of AUser objects, it is an attribute of instances of the AGroup class [[group valueForKey:@"users"] isEqualToSet:members] AGroup - users AUser - name (String) How do I check if the sets are equal by checking their name attributes? Sorry for my lack of knowledge, it

How to use NSPredicate to filter NSMutableSet which contains composite object from other Class?

淺唱寂寞╮ 提交于 2019-12-22 18:04:07
问题 Newbie Questions, I have 3 Class, 3 of them are subclass from NSOBject. Collection Class , have 2 properties, masterSong as NSMutableSet (strong, nonatomic) and listOfPlaylists as NSMutableArray (strong, nonatomic) Playlist Class Have 2 properties, playListName as NSString (copy, nonatomic) and songList as NSMutableArray (strong, nonatomic) 3 . Song Class Have 4 properties: title,artist,album, playtime as NSString (copy, nonatomic). masterSong will contain Song object, and listOfPlaylist will

Objective c - NSMutableSet unique object property

前提是你 提交于 2019-12-18 04:35:16
问题 In my app I have a class Person with personId property. Now I need some data structure to hold a bunch of unique Person objects (unique = different personId) So I guess I should use NSMutableSet as my data structure, but how do I make the NSMutableSet compare the personId property when adding a person (so I won't add the same person more then ones)? My goal is to have a collection of unique persons all the time (even if I add two persons with the same id), I want that the NSMutableSet will do

Store NSMutableSet to NSUserDefaults

心已入冬 提交于 2019-12-13 03:37:12
问题 I want to store a Swift Set in NSUserDefaults. Given that I can read a NSMutableSet value from UserDefaults using: UserDefaults.standard.mutableSetValue(forKey:) ... it seems like I should be able to write a NSMutableSet too. I tried converting my Set to NSMutableSet, but when I try to save it in UserDefaults it says: [User Defaults] Attempt to set a non-property-list object {( foo )} as an NSUserDefaults/CFPreferences value for key KEYNAME 回答1: mutableSetValue(forKey:) has an unfortunate

NSMutableSet contains Duplicates

戏子无情 提交于 2019-12-12 10:52:36
问题 I have a custom class called card and I need to create a set of 10 unique cards from an array of cards of a random size. Also, I need include any whitelisted cards first to make sure they are always included. My problem is cards from the whitelist (and only the whitelist) are potentially duplicated in the set. The cards randomly added are never duplicated, and the count is always correct (10). I can't figure out why isEqual seems to work sometimes but not always. Here is where I create the

NSMutableSet intput is not in the same order as output [closed]

只愿长相守 提交于 2019-12-12 00:43:47
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I have added objects into a NSMutableSet with this code: _theQuestionsSet = [[NSMutableSet alloc]initWithObjects:@802, @229, @522, @712, @628, @84, @412,

Protocol bridging NSMutableSet and NSMutableOrderedSet together

旧街凉风 提交于 2019-12-11 05:17:35
问题 In Swift 3 , I would like to be able to create a protocol which allows me to add elements and iterate through using for element in . The protocol should works on both NSMutableSet and NSMutableOrderedSet (since they do not inherit from the same class). I know there are good reasons why NSMutableSet and NSMutableOrderedSet do not inherit from the same class, it is explained here and here. But I want to create a protocol which only makes use of a fraction of all the methods inside NSMutableSet