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

Proper way of method swizzling in objective-C

Currently experimenting with method swizzling in Objective-C and I have a question. I am trying to understand the proper way to method swizzle and after researching online I stumbled upon this NSHipster…
AyBayBay
  • 1,726
  • 4
  • 18
  • 37
7
votes
1 answer

HLSL Swizzle - in C#

I am looking for a way to implement the swizzle functionality found in HLSL in C#, for those of you unfamiliar with what this is - it is used for easy vector element access. Vector4 v1, v2; // (t,x,y,z) or (alpha,r,g,b) v1 = new Vector4…
user164771
6
votes
5 answers

How do disk pointers work?

Suppose I want to store a complicated data structure (a tree, say) to disk. The internal pointers which connect nodes in my data structures are pointers, but I can't just write these pointers to disk, because when I read the data structure back the…
Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99
5
votes
2 answers

Copy a method IMP for multiple method swizzles

I have a class set up that ideally will read the methods of any class passed in and then map all of them to on single selector at runtime before forwarding them off to their original selector. This does work right now, but I can only do it for one…
Jack Freeman
  • 1,414
  • 11
  • 18
5
votes
1 answer

iOS blurred text: detecting & solving it once and for all?

More than once I've encountered the situation where a UIView (subclass) ends up on a fractional offset, e.g. because its dimensions are odd and it's centered, or because its location is based on the center of an odd-sized container. This results in…
mvds
  • 45,755
  • 8
  • 102
  • 111
5
votes
1 answer

Can I swizzle didSelectRowAtIndexPath: of UITableViewDelegate?

The problem is this: I need to be able to get analytics on didSelectRowAtIndexPath throughout a big existing app with lots of tableViews. My first thought of this is doing method swizzling on didSelectRowAtIndexPath: but my app crashes with…
Horatiu Paraschiv
  • 1,750
  • 2
  • 15
  • 37
5
votes
2 answers

Swizzling a method with variable arguments and forward the message - Bad Access

I'm implementing a "Code Injector Class", that through method swizzling can give you the possibility to do something like this: FLCodeInjector *injector = [FLCodeInjector injectorForClass:[self class]]; [injector…
LombaX
  • 17,265
  • 5
  • 52
  • 77
5
votes
1 answer

My isa-swizzling breaks KVO

I'm trying to implement isa swizzling because I need some actions to happen in dealloc method of certain object. I'm overriding - (Class)class; method to return original class (as KVO does). Everything works fine, until I try to add observer to…
4
votes
1 answer

Objective C Method Swizzling using dynamic library

I am trying to learn method swizzling. I have created a program in objective C which just calls a method within its class. Now my I am trying to load a dynamic library using DYLD_INSERT_LIBRARIES so I can override my method implementation with new…
user1259893
  • 199
  • 1
  • 4
4
votes
2 answers

Method swizzling for NSArray

I'm trying to debug something on an NSArray and I can't even find what the pointer to the array that's causing the issue is and I have no idea why it's happening. I'm getting an error on objectAtIndex: (out of bounds) and it seems to be coming from…
anon
  • 43
  • 4
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(_…
4
votes
1 answer

iPhone: I've come up with an interesting way I could get around an API limitation. Will this work?

The problem that I'm trying to solve is this: When using a UIImagePicker, it adjusts itself as the device is rotated. I don't want it to do this, rather it should constantly stay in the portrait orientation. I've googled aplenty and haven't found…
Jordan Smith
  • 10,310
  • 7
  • 68
  • 114
4
votes
1 answer

willMoveToWindow is called twice

I'm swizzling willMoveToWindow: and I came across an issue where it was being called twice on views. When a new view controller is pushed onto a UINavigationController, willMoveToWindow: is called on the existing view with nil value (Makes sense…
Avba
  • 14,822
  • 20
  • 92
  • 192
4
votes
1 answer

'Swizzle' (Maybe by Reflection?) addView() On Android

I'm aware you cannot actually Swizzle in Java. I was doing some research and I think 'maybe' you can do Reflection in Java to accomplish Swizzle like behaviour (that you can do on iOS). The culprit (and one of the worst design decisions I've ever…
Aggressor
  • 13,323
  • 24
  • 103
  • 182
4
votes
1 answer

how can i swizzle corefoundation framework methods?

I followed this article for objective-c method swizzling. I'm successfully able to swizzle methods objective -c class methods. I also want to swizzle core foundation methods like CFHostCreateWithName(). Is it possible to swizzle core foundation…
1
2
3
10 11