当前位置:网站首页>swift 代码实现方法调用
swift 代码实现方法调用
2022-06-26 08:10:00 【may_he】
class X {
@objc func sayHiTo(name: String) {
print("Hello \(name)!")
}
}
let obj = X()
let sel = #selector(obj.sayHiTo)
let method = class_getInstanceMethod(object_getClass(obj), sel)
let imp = method_getImplementation(method)
typealias ClosureType = @convention(c) (AnyObject, Selector, String) -> Void
let sayHiTo : ClosureType = unsafeBitCast(imp, ClosureType.self)
sayHiTo(obj, sel, "May")
边栏推荐
- QT之一个UI里边多界面切换
- What is Wi Fi 6 (802.11ax)? Why is Wi Fi 6 important?
- Area of Blue Bridge Cup 2 circle
- MySQL practice: 3 Table operation
- Gavin teacher's insight on transformer live class - multi state transition of financial BOT and rasa interactive behavior analysis of Rasa project (52)
- Google Earth Engine(GEE) 02-基本了解和学习资源
- ReW_ p
- Jz-063- median in data stream
- Record the dependent installation problems encountered in building the web assets when developing pgadmin
- Chapter 9 (using classes and objects)
猜你喜欢

I want to create SQL data (storage structure)

Ora-12514: tns: the listener currently does not recognize the service requested in the connection descriptor

Arrangement and insertion structure

StarWar armor combined with scanning target location

Double linked list -- tail interpolation construction (C language)

Junit

Read excel table and render with FileReader object

OSPF design principles, commands take H3C as an example

Google Earth Engine(GEE) 01-中输入提示快捷键Ctrl+space无法使用的问题

Baoyan postgraduate entrance examination interview - operating system
随机推荐
Livevideostackcon | evolution of streaming media distribution for online education business
Handwritten instanceof underlying principle
Win11 open folder Caton solution summary
Use of jupyter notebook
Common uniapp configurations
ReW_ p
The difference between setstoragesync and setstorage
Chapter VI (pointer)
[UVM basics] understanding of sequence and sequencer
Database learning notes I
JMeter performance testing - Basic Concepts
ECE 9203/9023 analysis
Web technology sharing | webrtc recording video stream
Basic use of swiperefreshlayout, local refresh of flutterprovider
Leetcode topic [array] -11- containers with the most rainwater
What if the service in Nacos cannot be deleted?
Quickly upload data sets and other files to Google colab ------ solve the problem of slow uploading colab files
Pychart connects to Damon database
Baoyan postgraduate entrance examination interview - operating system
Multi interface switching in one UI of QT