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
46
votes
6 answers

How to implement method swizzling swift 3.0?

How can I implement method swizzling in Swift 3.0 ? I've read nshipster article about it, but in this code's chunk struct Static { static var token: dispatch_once_t = 0 } the compiler gives me an error dispatch_once_t is unavailable in Swift:…
Tikhonov Aleksandr
  • 13,945
  • 6
  • 39
  • 53
32
votes
2 answers

How to swizzle a class method on iOS?

Method swizzling works great for instance methods. Now, I need to swizzle a class method. Any idea how to do it? Tried this but it doesn't work: void SwizzleClassMethod(Class c, SEL orig, SEL new) { Method origMethod = class_getClassMethod(c,…
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
25
votes
2 answers

App Store - Method Swizzling Legality

Is there any current information on wether or not method swizzling is legal/illegal on the App Store? The only data point I can find is the Three20 framework shakeup a while back, which started with this notice: Your application, xxx, currently…
ultramiraculous
  • 1,062
  • 14
  • 21
25
votes
1 answer

Method Swizzle on iPhone device

I tried both JRSwizzle, and MethodSwizzle. They compile fine on the simulator but throw a bunch of errors when I try to compile for Device (3.x) Has anyone had any luck swizzling on the iphone? Whats the trick? TIA
dizy
  • 7,951
  • 10
  • 53
  • 54
20
votes
8 answers

Swift function swizzling / runtime

Before Swift, in Objective-C I would swizzle or hook methods in a class using . If anyone has any info on the topic of modifying Swift's runtime and hooking functions like CydiaSubstrate and other libraries that helped in this area,…
atomikpanda
  • 1,845
  • 5
  • 33
  • 47
19
votes
3 answers

Swizzling a single instance, not a class

I have a category on NSObject which supposed to so some stuff. When I call it on an object, I would like to override its dealloc method to do some cleanups. I wanted to do it using method swizzling, but could not figure out how. The only examples…
Gilad Novik
  • 4,546
  • 4
  • 41
  • 58
18
votes
3 answers

Is there an alternative to initialize() in macOS now that Swift has deprecated it?

Objective-C declares a class function, initialize(), that is run once for each class, before it is used. It is often used as an entry point for exchanging method implementations (swizzling), among other things. Its use was deprecated in Swift…
Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
14
votes
1 answer

ios - swizzling of firebase cloud messing

I am working with an app using Firebase Cloud Messaging for Push Notification. After reading its documentation, I have a little confuse about "Swizzling disabled", I tried to find some tutorials which are talking about it, but unfortunately there is…
11
votes
2 answers

Calling original function from swizzled function

I am messing around with method swizzling and would like to call the original function after performing a method_exchangeImplementations. I have two projects I have setup for this. The first project is the main project for the application. This…
Corey Gagnon
  • 113
  • 1
  • 4
10
votes
1 answer

Are method swizzling and isa swizzling the same thing?

Are method swizzling and isa swizzling the same thing? If not, then what is isa swizzling?
Mayank
  • 643
  • 8
  • 19
9
votes
2 answers

How do I implement method swizzling?

I am trying to modify behaviour of a program (i dont have it's source) using SIMBL. I used class dump and found out that I need to overide an instance method This method is in the class called controller. All I need to do is get the argument arg1…
user635064
  • 6,219
  • 12
  • 54
  • 100
9
votes
1 answer

How to swizzle a method of a private class

I have a private class (both declared & defined within .m) as an addition to an implementation of a different class, that happens to use that private class internally. I'd like to swizzle one of the methods of that private class. I defined a…
Jacob K
  • 2,669
  • 1
  • 15
  • 20
8
votes
2 answers

Firebase Cloud Messaging Notifications for iOS not showing opened and analytics

I'am using FCM to send notifications to iOS apps. The notifications are received on the device well, but I can not get the "Opened" or "Conversion " rate in the Notification console GUI. It always shows "0 opened" and "0 Conversion" for almost 200…
Ericbcn
  • 191
  • 2
  • 6
7
votes
1 answer

Method swizzling in swift 4

Swizzling in Swift 4 no longer works. Method 'initialize()' defines Objective-C class method 'initialize', which is not permitted by Swift This is something I have found a solution to so wanted to leave the questions and answer for others.
Christopher Rex
  • 392
  • 3
  • 10
7
votes
3 answers

How to call original implementation when overwriting a method with a category?

I try to figure out how things really work. So I thought when I would overwrite certain methods using categories, I would get interesting NSLogs. @implementation UIView(Learning) - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { …
Proud Member
  • 40,078
  • 47
  • 146
  • 231
1
2 3
10 11