Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I've solved it.</p> <p>First I created a category on NSBundle, and created new implementations of pretty much every method related to loading files from the bundle, until I found the one Qualcomm are using, which is:</p> <pre><code>- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath; </code></pre> <p>Once I had that, I changed my category method to be:</p> <pre><code>#define XFILPATH4DOCUMENT(_value) [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:_value] - (NSString *)pathForResourceOverride:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath { if (([name isEqualToString:@"config"] &amp;&amp; [ext isEqualToString:@"xml"]) || ([name isEqualToString:@"qcar-resources"] &amp;&amp; [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]; } } </code></pre> <p>Then, through the magic of method swizzling:</p> <pre><code>Swizzle([NSBundle class], @selector(pathForResource:ofType:inDirectory:), @selector(pathForResourceOverride:ofType:inDirectory:)); </code></pre> <p>Using this method:</p> <pre><code>#import &lt;objc/runtime.h&gt; #import &lt;objc/message.h&gt; 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); } </code></pre> <p>Which I got from the answer here: <a href="https://stackoverflow.com/questions/1637604/method-swizzle-on-iphone-device">Method Swizzle on iPhone device</a></p> <p>Scary? Yes.</p> <p>But it works.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload