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
0
votes
0 answers

Swizzle a class method and a instance method

I have some weird requirement to swizzle a class method with an instance method. Basically, they are in different classes A & B. A has a static function called public static func aTest() {} B is a singleton with a function static let…
Oliver Hu
  • 148
  • 7
0
votes
1 answer

Swizzling Not Working in a framework

I'm developing an iOS framework and need to write a swizzling method (for viewDidAppear method in UIViewController). My swizzling method works perfectly in my application. But when I cut/paste my header+implementation files to my framework and…
tdebroc
  • 1,436
  • 13
  • 28
0
votes
2 answers

Swizzle a class without an instance of it

I need to swizzle a class that I don't have a reference to at the point I'm trying to swizzle at. I'm using the "indie" swizzling method so that I can swizzle any class from anywhere, but it requires an instance of that class to get the Class…
Earlz
  • 62,085
  • 98
  • 303
  • 499
0
votes
2 answers

Objective-C hooking to [AppDelegate openUrl]

Environment xcode 6.4 Objective-C iOS Application Use-case The product is a SDK integrated in 3rd party apps No Access to the source-code of the application using the SDK Modules in the SDK should retrieve the URL Used to start the application (…
NadavRub
  • 2,520
  • 27
  • 63
0
votes
1 answer

Swizzling - Undo method selector swizzling in Objective-C iOS

We're making use of Swizzling in Objective-C. For convenience we're using CoconutKit's helper methods to achieve this: HLSSwizzleSelectorWithBlock_Begin([TMObjectCache class], @selector(objectForKey:)) ^(TMObjectCache *self, NSString *key) { …
Gaurav Sharma
  • 2,680
  • 3
  • 26
  • 36
0
votes
1 answer

Not able to swizzle NSOutputStream's write:MaxLength:

I have a requirement of writing a custom data, before the actual write of NSOutputStream happens. To make swizzling code execute, i have created a category NSOutputStream(SwizzleWrite), which contains the following: SEL originalSelector =…
0
votes
3 answers

cannot get __NSCFURLSession class under ios 8

I have code snippet like this c = NSClassFromString(@"__NSCFURLSession"); Using ios 7 simulator , I was able to get c c Class __NSCFURLSession 0x00000001113a2ce8 but under ios 8, I am getting c Class 0x0 0x0000000000000000 Does anyone…
jqyao
  • 170
  • 6
0
votes
1 answer

How should CategoryA override categoryB method

In AFNetworking 2.0, in UIImageView+AFNetworking there is a method: + (id )sharedImageCache I want to override it and return here my custom object. I'd like also to override all the methods in AFImageCache, so basically I'd make a new…
Nat
  • 12,032
  • 9
  • 56
  • 103
0
votes
1 answer

Method Swizzling not firing correctly?

I am following this article to better understand how method swizzling works. I have my main view controller (this is a new project) like this: #import "GLViewController.h" #import @implementation UIViewController (Tracking) +…
George L
  • 1,673
  • 2
  • 26
  • 39
0
votes
2 answers

Why does this swizzle of UIAlertView's alloc method cause a recursion?

I'm playing around with swizzling, and can't quite figure this out. My alloc swizzle looks like this: @interface UIAlertView (Custom) + (id)allocCustom; @end @implementation UIAlertView (Custom) + (void)load { Method original; Method…
Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
0
votes
1 answer

Swizzling Copy method of UIResponder

I am swizzling Copy: and Paste: method of UIResponder. I have to write the copied content to a private pasteboard. - (void)copyToPrivatePasteboard:(id)sender { UIPasteboard *privatePasteboard = [self getPrivatePasteboard]; [privatePasteboard…
chandvoid
  • 133
  • 1
  • 12
0
votes
1 answer

Method Swizzling Implementation not taking place

I am trying to learn the concept of swizzling. Even though I have added method_exchangeImplementations, still the methods are not being swizzled. Any idea as to where I am going wrong? #import @interface POCViewController () -…
footyapps27
  • 3,982
  • 2
  • 25
  • 42
0
votes
1 answer

Is it possible to replace method of all objects using it as implementation of a protocol?

Is it possible to replace method of all objects using it as implementation of a protocol? The method is canPerformAction:(SEL)action withSender:(id)sender: - (BOOL)myCanPerformAction:(SEL)action withSender:(id)sender { return NO; } The initial…
Dmitry
  • 14,306
  • 23
  • 105
  • 189
0
votes
1 answer

UIButton swizzling causing issue with UITableViewCellAccessoryType's

I have a class that swizzles UIButton's when the buttonType is UIButtonTypeCustom is true. However, this is also true when it comes to UITableViewCellAccessoryCheckmark and UITableViewCellAccessoryDisclosure is used as well. What is happening is…
Sebastien Peek
  • 2,528
  • 2
  • 23
  • 32
-1
votes
1 answer

How to swizzle UIApplication in iOS?

I need to Swizzle UIApplication class methods especially "application:handleOpenURL:". I have added a category class of UIApplication. I have exchanged my own method with the original method but, it never triggered. The Swizzle class called very…
Yuvaraj.M
  • 9,741
  • 16
  • 71
  • 100
1 2 3
10
11