Open NghiaTranUIT opened 3 years ago
Swizzle works fine:
class Person: NSObject {
let name: String
init(name: String) {
self.name = name
}
@objc dynamic func sayHi() {
print("Hi: \(name)")
}
}
class ViewController: UIViewController {
private var interposer: Interpose!
override func viewDidLoad() {
super.viewDidLoad()
do {
interposer = try Interpose(Person.self) {
try $0.hook(
#selector(Person.sayHi),
methodSignature: (@convention(c) (AnyObject, Selector) -> Void).self,
hookSignature: (@convention(block) (AnyObject) -> Void).self) {
store in { `self` in
print("Hi: Nghia v2")
}
}
}
let person = Person(name: "Nghia Tran")
person.sayHi()
} catch let error {
print(error)
}
}
}
We decide not to use InterposeKit since it's too complicated.
Description
InterposeKit is a modern framework that provides better swizzle functions. It's crucial for atlantis since we have to swizzle the original methods from NSURLConnection or NSURLSession in order to capture the request/response on the fly.
Acceptance Criteria