BenAY BenAY - 3 months ago 27
Swift Question

How to get initwithDictionary data into NSObject?

I created nsobject class but I dont know objective c method convert swift 2.How to call nsobject method other viewcontroller? and how to write this method with swift 2?

Sample Objective-C code:

-(id)initWithDictionary:(NSDictionary*)data
{
self=[super init];
if (self) {
NSString*action=[data objectForKey:@"action"];
NSString*status=[data objectForKey:@"status"];

if (NotNull(status)) {
self.status=[status intValue];
}
if (NotNull(action)) {
self.action=action;
}
}
return self;
}


Can you help me about this subject?
thank you.

Answer
init(dictionary : [String : AnyObject]) {
    super.init()

    self.setValuesForKeysWithDictionary(dictionary)
}
Comments