Music_Player3/MusicPlayer/MP/Common/Extension(扩展)/String.swift
Mr.zhou 96147c5e37 项目:Musicoo
版本:A面 1.0
构建:1.1
更新内容:对项目A面功能的实现,经测试确定各项功能无问题。
更新时间:2024年4月12日 11:20
上传状态:已上传App Connect
2024-04-12 11:19:58 +08:00

24 lines
817 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// String.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/7.
//
import Foundation
extension String {
/// type
func classFromString() -> AnyClass? {
// swift
var name = Bundle.main.object(forInfoDictionaryKey: "CFBundleExecutable") as? String
// '-'线'-''_'线
name = name?.replacingOccurrences(of: "-", with: "_")
// .
let fullClassName = name! + "." + self
// NSClassFromString()AnyClass?!
let anyClass: AnyClass? = NSClassFromString(fullClassName)
// type
return anyClass
}
}