Questions tagged [nsenumerator]

NSEnumerator is a key piece used to iterate over a collection in Objective-C. Specifically it is commonly used in unordered collections that do not have indices to traverse with. Example collection: NSSet

NSEnumerator is a key piece used to iterate over a collection in Objective-C. Specifically it is commonly used in unordered collections that do not have indices to traverse with. Example collection: NSSet

32 questions
41
votes
5 answers

Iterate over snapshot children in Firebase

I have a Firebase resource that contains several objects and I would like to iterate over them using Swift. What I expected to work is the following (according to the Firebase…
dfucci
  • 685
  • 1
  • 10
  • 17
20
votes
3 answers

How to use NSEnumerator with NSMutableDictionary?

How do I use NSEnumerator with NSMutableDictionary, to print out all the keys and values? Thanks!
Devoted
  • 177,705
  • 43
  • 90
  • 110
19
votes
3 answers

NSEnumerator performance vs for loop in Cocoa

I know that if you have a loop that modifies the count of the items in the loop, using the NSEnumerator on a set is the best way to make sure your code blows up, however I would like to understand the performance tradeoffs between the NSEnumerator…
Heat Miser
  • 19,438
  • 7
  • 35
  • 38
11
votes
3 answers

Fast Enumeration Vs NSEnumerator in Objective-C

I have seen this over and over, why exactly is it faster to use fast enumeration in loops rather than an NSEnumerator using nextObject:.
shreyasva
  • 13,126
  • 25
  • 78
  • 101
5
votes
3 answers

Doxygen fail to detect NS_ENUM in objective-c

I'm using Doxygen to document API written in Objective-C. Doyxygen fail to understand NS_ENUM typedef. I've found this solution but it did not work for me. ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES…
Ido Ran
  • 10,584
  • 17
  • 80
  • 143
3
votes
2 answers

How do I get the index of the current Object in an NSEnumerator iteration?

Question: How do I get the index of the current Object in an NSEnumerator iteration? (I don't want to keep track of things using an integer counter or use a for loop due to speed reasons. I did it before I just cannot remember how I did it...)
RexOnRoids
  • 14,002
  • 33
  • 96
  • 136
2
votes
1 answer

Watch next object in NSEnumerator

I have a NSEnumerator object with the text lines retrieved from a NSTextView, parsed with: NSEnumerator *myLines = [[allTheText componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] objectEnumerator]; I'm processing the lines…
Miguel E
  • 1,316
  • 2
  • 17
  • 39
2
votes
2 answers

Is NS_CLOSED_ENUM actually uneditable?

According the Apple docs, the new NS_CLOSED_ENUM macro added for Swift 5 is unchangeable. How is this possible? Can't I just clean the build, add a value, and recompile my app? Important Once an enumeration is marked as closed, it's a binary- and…
Jason
  • 13,563
  • 15
  • 74
  • 125
2
votes
0 answers

Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM:> was mutated while being enumerated

I am facing the above crash. I can able to understand that the above crash is due to mutating an array while it is enumerating. But I am using lot of arrays in that view controller. Is there a way to find the particular array that is causing the…
GJDK
  • 723
  • 2
  • 7
  • 19
2
votes
5 answers

When is NSEnumerator finished?

How do we know when enumeration is finished? The docs say: the return value of nextObject is nil when all objects have been enumerated. I was hoping to implement some "delegate-like" behavior whereby ... if (nextObject == nil) { do…
samfu_1
  • 1,160
  • 16
  • 30
2
votes
1 answer

What is the value of NSEnumerator?

when for . . . in . . . is available? Specifically, when we can write: NSArray *array; // array allocated and initialized here. for (id obj in array) { // do something to the object here } Why would we ever use an NSEnumerator?
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
1
vote
2 answers

NSSet of touchesShouldBegin: of UIScrollView is just one NSString

I have a subclass of UIScrollView, it is also the delegate. When I have the next protocol function called: - (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view { id element; NSEnumerator *setEnum = …
MiiChiel
  • 201
  • 1
  • 4
  • 14
1
vote
1 answer

Sorting arrays of file attributes by their creation date in Swift

I have been using Swift's [enumerator(at:includingPropertiesForKeys:options:)]1 to find all files within a given base path and create arrays for different resource keys (file name, path, creation date, etc). This has worked well, but I noticed that…
davwillev
  • 83
  • 10
1
vote
1 answer

How to get good grip on NSMutableDictionary, NSEnumerator, NSMutableSet?

I am little bit backward in knowledge on these three topics: NSMutableDictionary, NSEnumerator, NSMutableSet. When I want to use them, it feels very hard, even when I've gone through the developer documentation. Is there any sample code to…
Madan Mohan
  • 8,764
  • 17
  • 62
  • 96
1
vote
1 answer

typedef NS_ENUM: passing an NSDictionary of custom properties to method

I've created a macro like this, and a definition: #define CustomImageOptions NSDictionary typedef NS_ENUM(NSInteger, CustomImageOption) { CustomImageOptionResize, // CGSize CustomImageOptionQuality, // CGFloat CustomImageOptionType //…
brandonscript
  • 68,675
  • 32
  • 163
  • 220
1
2 3