iOS 2通过字符串 提取方法 并执行

1.1通过字符串 提取方法 并执行

SEL selector = NSSelectorFromString(@"dismissViewController:");

if ([self respondsToSelector:selector]) {

[self performSelector:selector withObject:self];

[self performSelector:selector];

}


swift

对应方法 public func perform(_ aSelector: Selector!) -> Unmanaged!

let selec = NSSelectorFromString("dismissViewController:")

if self.responds(to: selec) {

self.perform(selec)

self.perform(selec, with: self)

}

func dismissViewController(object:NSObject) -> Void {

NSLog("ss" )

}


1.2     字典的空值对象

  [NSNull null]

swift

var s = NSNull.init()

你可能感兴趣的:(iOS 2通过字符串 提取方法 并执行)