Thripthi Haridas
Thripthi Haridas

Reputation: 363

AFNetworking 3.0 get request Swift3.0

Have migrated code from swift 2 to swift 3. Getting error Value of type 'Any?' has no member 'value'. can anybody help me out AFNetworking with Swift3, totally stuck.

 let manager = AFHTTPSessionManager()

manager.get(
        ADS_URL,
        parameters: [],
        success: { (operation,responseObject) in
             self.loggedIn = responseObject.value(forKey: "success") as! Bool  // Error Value of type 'Any?' has no member 'value'


        },
        failure: { (operation,error) in
            sender!.setCMSError(error)
        }
    )

Upvotes: 0

Views: 856

Answers (1)

Maxim Aba
Maxim Aba

Reputation: 89

Swift 3 is very strict on types. You should downcast explicitly responseObject from the default Any? to an NSDictionary in order to apply directly to the value under the key ["success"].

Upvotes: 1

Related Questions