Questions tagged [nscountedset]

The NSCountedSet class declares the programmatic interface to a mutable, unordered collection of indistinct objects. A counted set is also known as a bag.

The NSCountedSet class declares the programmatic interface to a mutable, unordered collection of indistinct objects. A counted set is also known as a bag.

Each distinct object inserted into an NSCountedSet object has a counter associated with it. NSCountedSetkeeps track of the number of times objects are inserted and requires that objects be removed the same number of times. Thus, there is only one instance of an object in an NSSet object even if the object has been added to the set multiple times. The count method defined by the superclass NSSet has special significance; it returns the number of distinct objects, not the total number of times objects are represented in the set. The NSSet and NSMutableSet classes are provided for static and dynamic sets (respectively) whose elements are distinct.

While NSCountedSet and CFBag are not toll-free bridged, they provide similar functionality.

26 questions
0
votes
1 answer

NSCountedSet in an if statement

I am trying to NSLog the count of the number of @"1" inside of each label on my ViewController. I created 3 labels on the storyboard, then hooked up the IBOutlet. I added each of these labels into an NSMutableArray and alloc initWithObjects. I…
RubberDucky4444
  • 2,330
  • 5
  • 38
  • 70
0
votes
1 answer

NSCounted set ignoring a property

I'm trying to do a NSCountedSet but I need to ignore a property, I tried overriding the isEqual method of my object, and doing a manual compare of all the properties except the one I want to ignore but it doesn't work Any idea on how to achieve…
Jordi Puigdellívol
  • 1,710
  • 3
  • 23
  • 31
0
votes
4 answers

Check IF one String contains the same characters as another string

I am trying to write a function which will allow me to determine whether one NSString* contains the characters of another NSString*. As an example, refer to the below scenario: NSString *s1 = @"going"; NSString *s2 = @"ievngcogdl"; So essentially…
Maff
  • 1,032
  • 4
  • 25
  • 42
0
votes
1 answer

Keep NSArray original order in NSCountedSet

I have an NSArray and I need to get data from two keys and put together in a NSMutableDictionary. One key has stringvalues and the other NSNumbervalues. When I try to create NSCountedSetwithout adding the keys I want to use to separate arrays, it…
Jorge
  • 1,492
  • 1
  • 18
  • 33
0
votes
1 answer

Sorting an array by number of times an object appears in that array

I'm lost in a sea of sort descriptors, dictionaries, and counted sets. Hoping someone can help me find an easier way. Starting with a sorted array like this (of NSNumbers): ['7','7','7','5','5','5','5','5','5','3','2','2','2','2'] I want to end up…
soleil
  • 12,133
  • 33
  • 112
  • 183
0
votes
2 answers

NSCountedSet has no objects

I am trying to count the number duplicate objects that I have in an array. When I pass the array to my NSCountedSet function, it has no objects. From the examples I have seen, the usually pass NSArray to NSCountedSet where as I am passing an…
Kevin McFadden
  • 337
  • 1
  • 5
  • 23
0
votes
1 answer

Confusion with distinct and indistinct object

I thought that NSCountedSet counted numB and numC twice in the frequency because they had the same value, so I created two Fraction objects (not shown) from my class Fraction, and I set their ivars (numerator, denominator) to equal each others but…
Emily
  • 9
  • 2
0
votes
1 answer

How NSCountedSet works?

I have following code NSCountedSet *set = [[NSCountedSet alloc] init]; NSMutableString *lDesktopPath = [[NSMutableString alloc] initWithString:@"/Users/new/Desktop/"]; int i= 10; while (i) { NSLog(@"%@", [NSString…
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
-1
votes
1 answer

How to put and sort word in NSCountedSet in swift?

I'm try to getting most duplicated word from string with this code. let text = """ aa bb aa bb aa bb cc dd dd cc zz zz cc dd zz """ let words = text.unicodeScalars.split(omittingEmptySubsequences: true, whereSeparator: {…
alphonse
  • 687
  • 1
  • 6
  • 16
-1
votes
1 answer

NSSet & NSCountedSet object differentiation

I am working with NSSet and NSCountedSet and I have a question about how NSSet differentiate the object? Is it using the memory location? If I had 2 objects named car1 and I got the one from an array and the other downloaded from Internet will be…
BlackM
  • 3,927
  • 8
  • 39
  • 69
-1
votes
1 answer

Getting an error when creating an NSMutableString when iterating an NSCountedSet in Objective-C

I am iterating an NSCountedSet in a for-loop, and then trying to create an NSMutableString that is composed of the NSString object it holds, as well as the count for that particular object, and then insert the newly created NSMutableString into an…
syedfa
  • 2,801
  • 1
  • 41
  • 74
1
2