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
4
votes
1 answer

Can you swizzle application:didReceiveRemoteNotification:

I'm currently working on a product that needs to swizzle the AppDelegate's application:didReceiveRemoteNotification: (I don't want to call my new method in the appDelegate itself). The thing is: the swizzling simply doesn't work. I've already…
P. Unto
  • 236
  • 1
  • 11
4
votes
2 answers

Is there any way to monkey-patch or swizzle an NSArray (or other Class Cluster)?

Today I was working on a project in which I wanted to "alias" an alternative method for all instances of NSArray, and didn't think it would be too difficult with some good old-fashioned method swizzling. I broke out JRSwizzle and… [NSArray…
Alex Gray
  • 16,007
  • 9
  • 96
  • 118
4
votes
2 answers

SIMBL swizzling in finder

I manages to integrate Icon Overlay like dropbox in Mac Os Finder with a SIMBL plugin ! I Use the swizzle method to override some finder function. Here is my swizzle method : void PluginSwizzleInstanceMethod(Class cls, SEL oldSel, SEL newSel) { …
kavaliero
  • 389
  • 1
  • 4
  • 22
3
votes
1 answer

Swizzling low-level TCP methods on IOS

I am trying to find a way to get information on all the TCP traffic to and from my IOS application. The application is very simple and composed of a single UIWebView object. I tried to use swizzling on NSURLRequest but didn't have much luck with…
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
3
votes
2 answers

What exactly constitutes swizzling in OpenGL ES 2.0? (PowerVR SGX specifically.)

PowerVR says Swizzling the components of lowp vectors is expensive and should be avoided. What exactly is swizzling? color.brg // This fits the definition I'm familiar with. But what about vec3(color.b, color.r, color.g), or vec3(color),…
user652038
3
votes
1 answer

How can I call a Method that I saved using class_getInstanceMethod from Objective-C?

How do I call a method that I previously saved using the code below: SEL sel = @selector(someMethod:param:); Method myMethod = class_getInstanceMethod([SomeClass class], sel); As you may imagine, calling [SomeClass someMethod] is not going to…
sorin
  • 161,544
  • 178
  • 535
  • 806
3
votes
1 answer

ios swizzle better understanding

I have a UIViewController with this code: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSLog(@"CLASIC"); } And then I have a framework with a UIViewController category that does swizzling in this manner: +…
Catalin
  • 1,821
  • 4
  • 26
  • 32
3
votes
1 answer

How to create categories dynamically in objective c?

I'm working on an objective-c library project ('MyLib'). Let's say this library is then included in 'TestApp'. Now, 'TestApp' also includes another library called 'Xlib'. This Xlib has a class C1 which has a method m1. //C1.h is part of…
3
votes
0 answers

Firebase Method Swizzling doesn't work

I'm building an iOS app and using Firebase Cloud Messaging to do remote notifications. I've done nothing to disable swizzling (haven't touched the FirebaseAppDelegateProxyEnabled flag), though the swizzling doesn't appear to be enabled. The function…
3
votes
1 answer

Swizzling on properties that conform to UI_APPEARANCE_SELECTOR

I am trying to swizzle the backgroundColor property on UIView. Before I swizzle, I do the following: @implementation UIView (Cat1) +(void)load { NSArray *selectors = @[ //Highliter swizzling …
yanivH
  • 67
  • 8
3
votes
1 answer

UIView method swizzling swift 3

I'm trying to implement method swizzling in swift 3 basing on answer How to implement method swizzling swift 3.0? Here's my code: // MARK: - Swizzling private let swizzling: (UIView.Type) -> () = { view in let originalSelector =…
art-of-dreams
  • 241
  • 3
  • 12
3
votes
2 answers

Is it possible to swizzle deinit using swift. if yes then how to achieve this

I want to log some statements in deinit in each subclass of UIViewController in my project. I don't want to copy/paste the same lines in each view controller subclass.
ZaEeM ZaFaR
  • 1,508
  • 17
  • 22
3
votes
2 answers

how to swizzle NSURLConnectionDataDelegate methods?

Is it possible to swizzle connection:didReceiveResponse: and connection:willsendrequestforauthenticationchallenge: delegate methods. If Yes, Please suggest me a way to do this. I am able to swizzle initwithrequest: method but I am not able to…
Madhu Avinash
  • 933
  • 2
  • 8
  • 27
3
votes
2 answers

Difference between method swizzling and category in Objective c

I was just understanding the method swizzling done in obj c Method Swizzling and dangers of using method swizzling and couldn't help but draw a comparison between doing method swizzling and overwriting method implementation using categories. They…
dead_soldier
  • 429
  • 1
  • 5
  • 18
3
votes
0 answers

Swizzle method for all subclases

I have CLLocationManager class with method setDelegate:. Also I have inheritance classes in closed frameworks. I want to exchange implementation setDelegate: for this class and all inheritance. NSArray *sfl_classGetSubclasses(Class parentClass) { …
Gralex
  • 4,285
  • 7
  • 26
  • 47
1 2
3
10 11