Questions tagged [swizzling]

Swizzling refers to the extraction, rearrangement, and possible duplication of elements of tuple types. On many GPUs swizzling is free or at least cheap, and smart use of swizzling can make your code more efficient. However, inappropriate use of swizzling can also make your code incredibly hard to read, and may make it hard for the compiler to optimize it.

Swizzling refers to the extraction, rearrangement, and possible duplication of elements of tuple types. On many GPUs swizzling is free or at least cheap, and smart use of swizzling can make your code more efficient. However, inappropriate use of swizzling can also make your code incredibly hard to read, and may make it hard for the compiler to optimize it.

Matrices may also be swizzled, but they require two swizzle operations in sequence. The first (leftmost) swizzle is a swizzle on rows, the second (rightmost) swizzle is a swizzle on columns. This notation permits permutation of rows and columns as well as the extraction of submatrices.

See Swizzling and Write Masking.

151 questions
1
vote
2 answers

is it possible to swizzle the keyword `throw`?

I was thinking about error handling and I learned about swizzling recently. Swizzling is certainly a tool which shouldn't be used too often, and I think I understand that, but it made me wonder. If whenever an error is thrown, if I wanted to capture…
Tiny Tim
  • 207
  • 1
  • 6
1
vote
3 answers

Swizzling +[NSObject initialize] method to log each class instantiation

Basically, I want to print each time a class object is instantiated. The following code shows the intent. @interface NSObject (ILogger) + (void)initialize; @end @implementation NSObject (ILogger) + (void)initialize { NSLog(@"Initializing %s",…
A. K.
  • 34,395
  • 15
  • 52
  • 89
1
vote
1 answer

How should I replace an instance of a class in the system with a subclass in Objective-C?

I have subclassed a system class (UINavigationBar, to be specific) to add some specific functionality. I've been using this everywhere, as a replacement for UINavigationBar. However, now I want to replace some UINavigationBars used in system…
Tom H
  • 1,316
  • 14
  • 26
1
vote
0 answers

IOS Swizzling the best newest way to do it today

We have an IOS swift code that is doing swizzling by using method_exchangeimplementations But this a method since 2014 And it is causing our app to crash when using new relic. Is there a newer better way to do it today in year 2022? I read about…
Ziv Adler
  • 169
  • 2
  • 11
1
vote
1 answer

Vector Swizzling in JavaScript: Best Methods

If swizzling is possible in JavaScript, what would be the best way or a good start to vector swizzling? It would be similar to swizzling in other programming languages, for instance, glsl: vec3 v = vec3(fragCoord.xy, 0); Something like this should…
1
vote
0 answers

Will using DYLD_INTERPOSE for a C function in one iOS static library interpose it for all other libraries in the bundle?

I have a static library objective c with some C functions that I need to modify the behavior of based on the callers. I looked at https://opensource.apple.com/source/dyld/dyld-210.2.3/include/mach-o/dyld-interposing.h and saw that it could be used…
gran_profaci
  • 8,087
  • 15
  • 66
  • 99
1
vote
0 answers

Using the Objective-C runtime in Swift to dynamically call Objective-C methods returns invalid UnsafePointer

I am attempting to use the Objective-C runtime in Swift to dynamically call Objective-C methods using method_getImplementation. My approach works well for methods that either return void or that return an object, but it breaks when attempting to…
S.Moore
  • 1,277
  • 17
  • 17
1
vote
0 answers

UISceneDelegate of Method Swizzling in iOS13?

iOS 13 has a new way of sending app lifecycle events: @implementation SceneDelegate - (void)sceneDidDisconnect:(UIScene *)scene { } - (void)sceneDidBecomeActive:(UIScene *)scene { } - (void)sceneWillResignActive:(UIScene *)scene { } -…
iHTCboy
  • 2,715
  • 21
  • 20
1
vote
2 answers

OpenGL grayscale texture as float wrong format

I got an array with floating point values in 0.0 - 1.0 range (a height-map) but the texture comes back either black or just red I've tried multiple combinations of internal and source formats but nothing seems to work. My current code that just…
user1031204
  • 701
  • 1
  • 8
  • 30
1
vote
1 answer

Swizzling in iOS

If we a new enhancement project within which we need to integrate FCM notifications we need to know swizzling is enabled or enabled . How to know swizzling method is enabled or disabled in our project?
UseriOSDev
  • 105
  • 11
1
vote
1 answer

Implement unhandled protocol method in extension

I'm trying to implement some push notification methods in my Cordova plugin. Cordova creates their own UIApplicationDelegate, called CDVAppDelegate, so I tried to extend that and use swizzling to add my methods. However, when I implement an…
Crag
  • 1,723
  • 17
  • 35
1
vote
2 answers

Method Swizzling - How to assure methods are swizzled before they are called

I'm method swizzling a third party applications creation of NSMenuItems with SIMBL, but 50/50 of the time the menu-items are created before my method swizzling is initialized. What is a clean way to make sure my swizzling always comes first? I…
1
vote
0 answers

Swizzle Tap Gesture Action in iOS Cocoa Touch Framework

I am developing an Cocoa Touch Framework or a dynamic Library which would capture user actions using Swift. E.g. When a user taps on a label, my framework should know about it. For achieving this behaviour, I am using method swizzling. I am…
schinj
  • 794
  • 4
  • 19
1
vote
1 answer

SIMBL with Method Swizzling

I have some great troubles overriding some functions in an external App that I use SIMBL to hook in to. In this app, there is a class - let's call it "AppClass". In this class there is a function, -(void)doSomething; I got this from class-dumping…
1
vote
2 answers

Firebase Dynamic Link can't find continueUserActivity when Localytics implemented

While implementing Firebase Dynamic link on iOS, there is an error message in the debugging console when you click open dynamic link: FIRAnalytics/WARNING Implementation of application:continueUserActivity:restorationHandler: not found. Please add…
Breek
  • 1,431
  • 13
  • 24