代码语言:javascript复制
/// 在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;
}