Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Fykec opened this issue Mar 2, 2012 · 3 comments
Open

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

Fykec opened this issue Mar 2, 2012 · 3 comments

Comments

@Fykec
Copy link

Fykec commented Mar 2, 2012

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!

@rentzsch
Copy link
Owner

rentzsch commented Mar 2, 2012

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

@Fykec
Copy link
Author

Fykec commented Mar 3, 2012

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 <Foundation/Foundation.h>

@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.

@brendanjerwin
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants