I want to swizzle URLSession class method data(for:)
but not been able to get it done.
I tried this swizzling in Swift but it not working, bellow is the error:
the code:
#selector(URLSession.data(for:))
Please help me.
Update 1:
My Problem:
I have swizzle URLSession with
#selector(URLSession.dataTask(with:) as (URLSession) -> (URLRequest) -> URLSessionDataTask)
and
#selector(URLSession.dataTask(with:) as (URLSession) -> (URL) -> URLSessionDataTask)
.
It works fine before iOS 16+ with the follow code: try await URLSession.shared.data(for: request)
. I don't know why, So, I want swizzle the data(for:)
method to test my guess, but it fails.