changing the implementation of an existing selector in Objective-C.
Questions tagged [swizzle]
21 questions
13
votes
3 answers
Debugging Core Data __NSCFSet addObject nil exception
I'm getting exceptions thrown during my unit tests, on a Core Data thread with this message:
CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of…

Dov
- 15,530
- 13
- 76
- 177
5
votes
2 answers
How to swizzle init in Swift
I'm following Swift & the Objective-C Runtime, it works for normal methods.
I like to swizzle init method, from my understanding, init is like a class method. So I tried swizzling init as instance and class method. But it does not seem to work
I can…

onmyway133
- 45,645
- 31
- 257
- 263
4
votes
2 answers
how to swizzle didReceiveRemoteNotification of AppDelegate from framework
I'm developing a framework for iOS apps (a pod). I want to swizzle
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
with a method defined in my framework. this is my code:
class MyClass {
@objc
func myCustomizedMethod(_…

Jafar Khoshtabiat
- 665
- 8
- 27
2
votes
1 answer
How can I swizzle UIView.init
I’m attempting to swizzle the init methods of UIView and anything that subclasses it. Thus far my attempts only lead to crashes or simply do nothing noticeable.
The outcome in trying to achieve is being able to override the value of the views border…

Brandon Stillitano
- 1,304
- 8
- 27
1
vote
0 answers
Docusaurus swizzled plugin, DocNavbarItem: couldn't find any doc with id "undefined" in version current"
I am trying to create a custom Docusaurus package. In this package I am trying to swizzle the DocNavbarItem component. I am able to get my plugin enabled in Docusaurus, but when I try to run the code I get this error:
This page…

Jonathan Peck
- 11
- 1
1
vote
1 answer
Is there a way to get a generic call to any UIButton's method selector?
I've recently come across the technique of swizzling. It looks like it's not a super common practice to use and I can understand the drawbacks I keep seeing listed for it. But as it's a thing that we can use in swift, I was hoping I could throw…

Tiny Tim
- 207
- 1
- 6
1
vote
1 answer
How to exclude UIViewControllers other than views from Swizzle Method?
I am trying to override viewDidAppear() methods of my custom ViewControllers and i found a solution using swizzle method. It works but when keyboard is visible, my method also gathers Keyboard UIViewControllers like;
UIInputWindowController
…

Neco
- 55
- 1
- 1
- 5
1
vote
0 answers
Template deduction fails when using conversion operator but explicit casting works
I'm trying to implement swizzle vectors in C++ with template programming. With swizzle vectors I mean vectors similar to hlsl and glsl vectors where for example if you have a vector v = (1,2,3,4) and do v.xxyz it produces the vector (1,1,2,3).
This…

Jim Nilsson
- 838
- 4
- 12
1
vote
1 answer
Is it possible to intercept all method class on any UIViewController subclass
Let's say I wanted to be able to intercept any method calls to a UIViewController subclass.
First of all, I swizzle the +(instancetype)alloc method and I check if the current instance isKindOfClass:[UIViewController class]. If it is I go ahead and…

iOSAddicted
- 389
- 1
- 17
1
vote
1 answer
How to properly swizzle UIScrollView with 3D touch peek pop?
I'm trying to swizzle the UIScrollView that 3D Touch's peek and pop preview is embedded in. (I know it's a UIScrollView through the Reveal app.)
I want to know whenever the user moves their finger on this scroll view/on the 3D touch preview.
I tried…

Doug Smith
- 29,668
- 57
- 204
- 388
0
votes
0 answers
How to monkeypatch (swizzle) the drawing methods of CGContext
Is there a way to listen when drawing on the CGContext occurres? For example: listen when beginPath, addRect are called and capture their params.
I'm trying to capture the UI on ios applications whenever a change happens.

Georgis Andonis
- 11
- 1
0
votes
0 answers
How to swizzle URLSession class method data(for:) in swift 5
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:))
the error:
Please help me.
Update 1:
My…

cnbleu
- 63
- 1
- 9
0
votes
0 answers
docusaurus swizzle, when I use swizzle of the docusaurus,I get an error: Hook use DocsSideBar is called outside the
when I use swizzle of the docusaurus,I get an error:
I want to ejecting a DocBreadcrumbs component.My project is based on rush, which node_modules is
The reason for the error is that I am missing some dependencies?
npx create-docusaurus@latest…

xll
- 1
0
votes
1 answer
Removing the cancel button in ASWebAuthenticationSession WebView
I am using a ASWebAuthenticationSession and want to remove the cancel nav bar button so the user cant close the window (mandatory verification needed to use the app)
I cant find a way to achieve this because the ASWebAuthenticationSession webview is…

jwarris91
- 902
- 9
- 24
0
votes
0 answers
How to call base class method when any method in subclass is being called?
I am working on XCUITest. My requirement in Swift is to have a takeScreenshot() method in the BasePage and capture screenshots when any method in SubPage:BasePage is being called without actually having to call takeScreenshot() method.
How can we…

avi rao
- 31
- 6