Devarshi
Devarshi

Reputation: 16758

How to iterate over an NSArrayController contents in swift?

I have an array controller which stores managed objects of entity 'Student', I am trying to iterate over its content using below code:

for (index, element) in downloadingFilesArrayController.arrangedObjects{
    // want to do some useful things on element
}

for some reasons it is showing compilation error:

'Type AnyObject does not conform to protocol SequenceType'

Any ideas on how can fix it?

Upvotes: 1

Views: 1272

Answers (1)

Himanshu gupta
Himanshu gupta

Reputation: 650

You can do something like this:

for element in downloadingFilesArrayController.arrangedObjects as! [AnyObject] {
    // want to do some useful things on element
}

Upvotes: 3

Related Questions