わかりました、私はそれを解決しました。
まず、NSBundleでカテゴリを作成し、Qualcommが使用しているものが見つかるまで、バンドルからのファイルの読み込みに関連するほぼすべてのメソッドの新しい実装を作成しました。
- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath;
それができたら、カテゴリメソッドを次のように変更しました。
#define XFILPATH4DOCUMENT(_value) [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:_value]
- (NSString *)pathForResourceOverride:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath
{
if (([name isEqualToString:@"config"] && [ext isEqualToString:@"xml"]) || ([name isEqualToString:@"qcar-resources"] && [ext isEqualToString:@"dat"]))
{
// OMG
NSString *fileName = [NSString stringWithFormat:@"%@.%@", name, ext];
NSString *path = XFILPATH4DOCUMENT(fileName);
NSLog(@"%@", path);
return path;
}
else
{
return [self pathForResourceOverride:name ofType:ext inDirectory:subpath];
}
}
次に、メソッドスウィズリングの魔法を通して:
Swizzle([NSBundle class], @selector(pathForResource:ofType:inDirectory:), @selector(pathForResourceOverride:ofType:inDirectory:));
この方法の使用:
#import <objc/runtime.h>
#import <objc/message.h>
void Swizzle(Class c, SEL orig, SEL replacement)
{
Method origMethod = class_getInstanceMethod(c, orig);
Method newMethod = class_getInstanceMethod(c, replacement);
if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
class_replaceMethod(c, replacement, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
else
method_exchangeImplementations(origMethod, newMethod);
}
私はここでの答えから得ました:iPhoneデバイスのメソッドSwizzle
怖い?はい。
しかし、それは機能します。