NSFastEnumerationIterator.Element (aka Any) does not conform to protocol 'AnyObject'
<p>After upgrading to Xcode 8 (Swift 3), my Firebase queries have the error <code>NSFastEnumerationIterator.Element (aka Any) does not conform to protocol 'AnyObject'</code> when I try to step through child records in a snapshot:</p>

<pre><code>for child in snapshot.children {
                if (child as AnyObject).value!["postedBy"] != nil { 
</code></pre>

<p>Xcode changed <code>child.value["postedBy"]</code> to <code>(child as AnyObject).value!["postedBy"]</code> which throws the error. I then tried changing it to </p>

<pre><code>((child as AnyObject).value as? NSDictionary)["postedBy"] != nil 
</code></pre>

<p>but then it throws a different error <code>Binary operator != cannot be applied to operands of type _ and _</code></p>

<p>Am I going in the right direction? Any help would be greatly appreciated.</p>

<p>Thanks!!</p>

<p><strong>Final solution:</strong></p>

<pre><code>for child in snapshot.children{
                if let postedBy = (snapshot.value as? NSDictionary)?["postedBy"] as? String {
</code></pre>