moaible / MOAspects

AOP Library for iOS
MIT License
163 stars 25 forks source link

Hooking some Swift class/instance method still fails in v0.1.5 #7

Closed 3ign0n closed 9 years ago

3ign0n commented 9 years ago

Hooking some subclasses of UITableView, written in swift, still fails. I don't know what's the difference between v0.1.4's behavior and v0.1.5's one. It works great for ones written in Objective-C, but forwardInvocation intercepted blocks will not be called for some Swift class/instance methods.

moaible commented 9 years ago

@3ign0n Hmm..., See the error log was not?

3ign0n commented 9 years ago

I got no error in Xcode console. I'll write some example code later.

moaible commented 9 years ago

@3ign0n

It works great for ones written in Objective-C, but forwardInvocation intercepted blocks will not be called for some Swift class/instance method.

I was confirmed. It is natural Swift method is only not working.

3ign0n commented 9 years ago

It works like a charm to add 'dynamic' keyword to a function. It's my workaround.

forwardInvocation for a pure Swift class/function may not work in a certain condition, I'm not sure what it is, but the function with 'dynamic' keyword will be dynamically dispatched through the Objective-C runtime.

moaible commented 9 years ago

@3ign0n Thank you for reporting! I confirmed 'dynamic' keyword solves this problem.

moaible commented 9 years ago

Closed.