Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Can i use swizzle a method witht a block implementation #5

Open
Fykec opened this Issue · 3 comments

3 participants

yinjiaji Jonathan 'Wolf' Rentzsch Brendan Erwin
yinjiaji

Hi, Jonathan

Can Can i use swizzle a method witht a block implementation

Normal swizzleMetod:(SEL)slector withSelctor:(SEL)newSelector

But I want this
swizzleMetod:(SEL)slector withBlock:(^ )block

because I cannot import WebView(In WebKit framework) to iOS project, but I want swizzle WebView's method, i cannot write a category for WebView, So I cannot find a place to put my newSector, so I want to use block,

Jonathan, can you give me some suggestions?

Thank You!

Jonathan 'Wolf' Rentzsch
Owner

Sounds like you should just write your own WebView.h with just the method you want to swizzle. No need for blocks.

yinjiaji

You I Write a WebView.h by myself, then write a category to swizzle method? I tried, but not ok
my WebView.h like this,

#import

@interface WebView : NSObject

@end

But in WebView's category still cannot find WebView When compile, my workmate suggest me to decompile the webkit code to my the WebView's method's list to rewrite the method than I want to swizzle, I think this maybe not so good, so
I am trying other solutions, thank you all the same.

Brendan Erwin

I too would like to be able to swizzle a method with a block for the implementation.

It nice and useful in a Unit Test (esp. Kiwi) where the closure behavior of blocks can be leveraged.

https://github.com/ebf/CTObjectiveCRuntimeAdditions provides such a method: class_replaceMethodWithBlock so it might be possible...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.