IOS reflection according to the operation on the Internet is not successful, what to do?

  1. Code in ViewController:

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let anyobjectype : AnyObject.Type = (NSClassFromString("testReflect.ABC"))!
    // testReflectname, ABCUIVIEW
    let nsobjectype : NSObject.Type = anyobjectype as! NSObject.Type
    let rec: AnyObject = nsobjectype
    let currentView: UIView = rec as! UIView
    
    self.view.addSubview(currentView)
}}
  1. The code in

    uiview
    class ABC: UIView {

    override init (frame: CGRect) {

    super.init(frame: frame)
    //
    print("you got it override init")
    self.backgroundColor = UIColor.green

    }

    required init? (coder aDecoder: NSCoder) {

    fatalError("init(coder:) has not been implemented")
    

    }
    / / Only override draw () if you perform custom drawing.
    / / An empty implementation adversely affects performance during animation.
    override func draw (_ rect: CGRect) {

    print("you got it draw")
    //self.backgroundColor = UIColor.brown

    }

}

-sharp-sharp-sharp uiview("ABC")

Jul.15,2021


//  nsobjectype  Class    
let nsobjectype : NSObject.Type = anyobjectype as! NSObject.Type
//  rec  Class
let rec: AnyObject = nsobjectype
//  currentView  Class 
let currentView: UIView = rec as! UIView
//  currentView  object,
//  : let currentView: UIView = rec() as! UIView
//   currentView 


//    self.view  add 
self.view.addSubview(currentView)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35283-2bf65.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35283-2bf65.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?