/// 在swift中使用NSClassFromString className要加工程名前缀
///
/// - Parameter className: className
func swiftClassFromString(className: String) -> AnyClass! {
// get the project name
if let appName: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String? {
// YourProject.className
let classStringName = appName + "." + className
return NSClassFromString(classStringName)
}
return nil;
}
I'm an indie developer and learning a little bit every day. persevere! effort! effort!