vendredi 14 août 2015

Pass argument in class method (+) of Objective-C class from Swift class

I am working with hybrid project of combination of Obj-C classes and Swift classes. I am little confuse at some point.

The scenario is like this, i have one Obj-C class call Util.h which have some class methods like bellow code

+ (id)dict_TO_Object:(NSDictionary *)dbData withObject:(Class)myObj {
      //Some code
      return obj;
}

Now, i have one Swift class called LoginVC.Swift. In this call i want to call dict_TO_Object method bellow is the code

let tmpDict:NSMutableDictionary
someVar = Util.dict_TO_Object(tmpDict as [NSObject : AnyObject], withObject: User.self())

//Above line give me an error
Error : Cannot invoke 'dict_TO_Object' with an argument list of type '([NSObject : AnyObject], withObject: User)'

in above code i am passing tmpDict and User as a class which is User.h in Obj-c

Please suggest me a solution or modification.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire