Pass Tuples as AnyObject in swift
From swift docs
You’ll have access to anything within a class or protocol that’s marked with the @objc attribute as long as it’s compatible with Objective-C. This excludes Swift-only features such as those listed here: 7 Generics
TuplesEnumerations defined in SwiftStructures defined in SwiftTop-level functions defined in SwiftGlobal variables defined in SwiftTypealiases defined in SwiftSwift-style variadicsNested typesCurried functions
For example, a method that takes a generic type as an argument or returns a tuple will not be usable from Objective-C.
So you can not use tuple
for AnyObject
as there is no matched objective c
object for tuple.Instead use Dictionary
to pass as parameter
Use dictionary instead
var abc:[String:AnyObject] = ["abc":123,"pqr":"not"]
you can use AnyObject for thar
Use this for your dictionary
let userState:[String:AnyObject] = ["name": "temp", "callingDate": NSDate(), "randomValue": 2345]