swizzling

Method swizzling for NSArray

梦想与她 提交于 2019-12-07 07:05:07
问题 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 some internal NSView method... anyway, I tried swizzling objectAtIndex: with my own, but it won't work. What's strange is I can do the same thing but with another class and method, and it works fine. Here's what I'm doing to swizzle: Class

What function/syscall is used by iOS to read and write files

左心房为你撑大大i 提交于 2019-12-06 16:03:05
I want to intercept file read/write on iOS for providing transparent encryption/decryption functionality to some of my apps. I know I can swizzle the various SDK methods for reading/writing files to do this, but that entails a LOT of hard work and is prone to error (I may miss swizzling some method, causing my application to crash/misbehave). If there is some common syscall/function used by all these methods, then I'd rather swizzle it and save on some hard work + make it more foolproof. Is there any such common entry point? PS: Acceptance into the app store is not a criteria here, since all

ShareKit method swizzling in Lion / Xcode 4.3.1?

天大地大妈咪最大 提交于 2019-12-06 07:30:49
I recently upgraded to Lion and Xcode 4.3.1 with the iOS 5 SDK, and the sharing library ShareKit is broken - it used method swizzling for its email handler. Apparently Apple has banned or at least attempted to phase out method swizzling. ShareKit imports a file </usr/include/objc/objc-class.h> , which no longer exists, and defines its own method swizzling method SHKSwizzle . It uses this to alter MFMailComposeViewController 's viewDidDisappear: method as follows: SHKSwizzle([MFMailComposeViewController class], @selector(viewDidDisappear:), @selector(SHKviewDidDisappear:)); What do you think is

Objective C Method Swizzling using dynamic library

有些话、适合烂在心里 提交于 2019-12-06 04:14:29
问题 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 method which is defined in my dynamic library. The aim is to modify the argument and then call the original function call. Program code is available at http://pastebin.com/a0b3qkgB The code for dynamic library is available at http://pastebin.com

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

萝らか妹 提交于 2019-12-06 02:26:30
问题 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 injectCodeBeforeSelector:@selector(aSelector:) code:^{ NSLog(@"This code should be injected"); }]; aSelector can be a method with variable number of arguments, and variable return type. Arguments / and return type can be objects or primitive type. First, I attach the code of

Copy a method IMP for multiple method swizzles

最后都变了- 提交于 2019-12-05 17:58:02
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 method at a time. The issue seems to be that once I swizzle the first method, my IMP to catch and forward the method has now been swapped with that other methods IMP. Any further attempts at this screw up because they use newly swapped IMP to replace the others. 1)So I have MethodA, MethodB, and CustomCatchAllMethod. 2)I swap MethodA with

Method swizzling for NSArray

不打扰是莪最后的温柔 提交于 2019-12-05 16:52:45
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 some internal NSView method... anyway, I tried swizzling objectAtIndex: with my own, but it won't work. What's strange is I can do the same thing but with another class and method, and it works fine. Here's what I'm doing to swizzle: Class arrayClass = [NSArray class]; Method originalMethod = class_getClassMethod(arrayClass, @selector(objectAtIndex:

SIMBL with Method Swizzling

我是研究僧i 提交于 2019-12-04 20:12:14
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 the Binary. the whole interface is defined as: @interface AppClass : NSObject { } I'm trying to override this function with jr_swizzleMethod:withMethod:error: With the lack of documentation, this is what I have come up with: #import "JRSwizzle.h" #import "AppClass.h" @interface AppClass (MyPlugin) - (void)myPlugin_doSomething; @end @implementation

Advice on how to catch “attempt to insert nil object” from a device needed

谁说胖子不能爱 提交于 2019-12-04 12:43:37
Here is a situation: Hockeyapp and testflight every now and then complain about me "attempting to insert nil object" in mutable dictionaries/arrays. I know the right thing is to check for nil all the time, and I do when it makes sense.. Our testers can not catch those crashes, but AppStore users obviously can. My guess is that sometimes server returns NSNulls when it should not. So not to insert checks for nil everywhere in the huge project my idea was to create a separate target for the testers and use method swizzling for collection classes. Say, I'll replace insertObject:atIndex with my

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

旧巷老猫 提交于 2019-12-04 07:19:43
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 injectCodeBeforeSelector:@selector(aSelector:) code:^{ NSLog(@"This code should be injected"); }]; aSelector can be a method with variable number of arguments, and variable return type. Arguments / and return type can be objects or primitive type. First, I attach the code of injectCodeBeforeSelector: to let you understand what I'm doing (I removed not interesting parts of the code): -