Sauron
Sauron

Reputation: 6657

Type 'NSFastEnumerationIterator.Element' (aka 'Any') does not conform to protocol 'AnyObject'

I am attempting to update my app to Swift 3.0 and and have arrived at the error: Type 'NSFastEnumerationIterator.Element' (aka 'Any') does not conform to protocol 'AnyObject'

on line:

        self.friends.append(Friend(userName: (detailData as AnyObject).value["userName"] as! String, phoneNumber: detailData.value["phoneNumber"] as! String, status: "Friend", statusSort: 2, name: detailData.value["userName"] as! String, userID: detailData.key))

How can I refactor this?

Upvotes: 2

Views: 363

Answers (1)

shallowThought
shallowThought

Reputation: 19602

Given your code, I asssume detailData is of type NSFastEnumerationIterator.Element:

You are casting a NSFastEnumerationIterator.Element to AnyObject:

(detailData as AnyObject)

but NSFastEnumerationIterator.Elements are structs, so change AnyObjectto Any:

(detailData as Any)

Upvotes: 1

Related Questions