swift中的坑

1.NSClassFromString


  //获取工程名称

  let group = Bundle.main.infoDictionary

  let fileName = group?[kCFBundleExecutableKey as String] as! String


//
LyRacDemo是工程名称,PersonClass是类的名称 -> NSClassFromString("工程名.类名") as? NSObject.Type

let modelClass = NSClassFromString("LyRacDemo.PersonClass") as? NSObject.Type
if modelClass != nil {
    let cl = modelClass?.init()
}

 

posted @ 2017-03-30 14:06  ZJea  阅读(235)  评论(0编辑  收藏  举报