Questions tagged [nsfastenumeration]

The fast enumeration protocol NSFastEnumeration must be adopted and implemented by objects used in conjunction with the for language construct used in conjunction with Cocoa objects.

The fast enumeration protocol NSFastEnumeration must be adopted and implemented by objects used in conjunction with the for language construct used in conjunction with Cocoa objects.

Click Here for class reference.

17 questions
15
votes
4 answers

SWIFT 3.0 migration error - Extension of a generic Obj-C class cannot access the class' generic parameter at runtime

I have this code working fine in Swift 2. extension PHFetchResult: Sequence { public func makeIterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(self) } } Since I upgraded to Swift 3 Extension of a…
rgoncalv
  • 5,825
  • 6
  • 34
  • 61
4
votes
3 answers

Why does loop variable become `nil` after loop

I have: NSDictionary* server; for (server in self.servers) { if () { break; } } // If the criterium was never true, I want to use the last item in the // the array. But turns out that `server` is `nil`. The…
4
votes
1 answer

NSFastEnumeration in Swift 3

I am trying to iterate over a object of CMSensorDataList class returned by CMSensorRecorder.accelerometerData(from:to:). This class confirms to NSFastEnumeration protocol. So I tried the trick mentioned in…
quarterest
  • 105
  • 1
  • 6
4
votes
2 answers

With NSPointerArray, how to iterate over opaque pointers?

I recently discovering these classes like NSMapTable and NSPointerArray, which work like the traditional collections, but also let you store weak references or plain old C pointers. Unfortunately it looks like you can't use the for...in syntax to…
Rob N
  • 15,024
  • 17
  • 92
  • 165
3
votes
1 answer

Getting NSGenericException with reason: '*** Collection was mutated while being enumerated.'

I get this NSGenericException with reason Collection was mutated while being enumerated even though I'm not actually use fast-enumeration in my code. This crash gets triggered when the NSFetchedResultsController…
Z S
  • 7,039
  • 12
  • 53
  • 105
3
votes
1 answer

How to implement countByEnumeratingWithState:objects:count: for class that internally use NSMutableArray

I wanted to use for (TBL_CardView *cardView in cardsInHand) { // <#statements#> } TBL_CardView is my custom class, and cardsInHand is just (TBL_CardViewArray*) So I need to implement countByEnumeratingWithState:objects:count: for…
WebOrCode
  • 6,852
  • 9
  • 43
  • 70
2
votes
2 answers

NSFastEnumeration object casting in ARC

I'm trying to implement the countByEnumeratingWithState:objects:count: method from the NSFastEnumeration protocol on a custom class. So far I have it iterating through my objects correctly, but the objects that are returned aren't Objective-C…
1
vote
1 answer

Is enumerateObjectsUsingBlock: faster than a for-in loop? Why?

I was reading the NSHipster article on enumeration, which claims that for-in loops are faster than enumerateObjectsUsingBlock:: Unless you actually need the numerical index while iterating, it's almost always faster to use a for/in…
paulrehkugler
  • 3,241
  • 24
  • 45
0
votes
1 answer

NSFastEnumeration message sent to deallocated instance

I am trying to implement the NSFastEnumeration protocol for a sqlite query. I am running into: message sent to deallocated instance - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf…
lostintranslation
  • 23,756
  • 50
  • 159
  • 262
0
votes
1 answer

Hot to Fix Type 'NSFastEnumerationIterator.Element' (aka 'Any') has no subscript members

Trying to get post's 'title','content', categorie's 'title' & author name out of this JSON. getting Error Type 'NSFastEnumerationIterator.Element' (aka 'Any') has no subscript members. printing post in console works fine but getting error while…
Hitz
  • 133
  • 1
  • 10
0
votes
0 answers

Disparity between Swift enumerator and GNU find

I have written a GNU find-like emulator in Swift out of curiosity, and have stumbled upon this time disparity: $ time find / &>/dev/null real 1m6.040s $ time swiftly-find / real 5m43.028s The Swift code is as follows: let enumeration =…
perhapsmaybeharry
  • 874
  • 3
  • 13
  • 32
0
votes
2 answers

NSFastEnumerationIteration.member Swift 3

I have some difficult to convert my Swift 2.2 app to Swift 3.0. I have some errors and I don't find the solution yet. Currently, my worst problem is with NSFastEnumerationIteration, I try to get records from JSON but with this error I can't. This is…
ewan
  • 276
  • 2
  • 17
0
votes
0 answers

NSFastEnumeration for class members

How do I implement NSFastEnumeration for my custom class which returns an enumeration of all class member variables? @interface Employee : NSObject @property (atomic, copy) NSString * name; @property (atomic, copy) NSString * designation; @property…
Seema Kadavan
  • 2,538
  • 1
  • 16
  • 31
0
votes
1 answer

How to get fixed number of subview from all subview of scrollview using fast enumeration in ios

How to select fix number of subview from all subview of scrollview using fast enumeration in ios?
Aashi
  • 170
  • 2
  • 14
0
votes
1 answer

iOS : Modifying NSFastEnumerationState to hide mutation while enumerating

I have a case where in my collections will be mutated while enumerating.But this is not allowed in iOS.On further investigation found that the NSFastEnumerationState is a c type struct as follows typedef struct { unsigned long state; …
Karthik207
  • 493
  • 9
  • 27
1
2