3

我正在尝试进行调整,使用 plist 文件来保存一些数据。
但是应用程序在启动过程中崩溃。

调整.xm:

#define hackBundlePath @"/Library/MobileSubstrate/DynamicLibraries/testBundle.bundle"

NSMutableDictionary *modsDict = [[NSMutableDictionary alloc] init];

%ctor {

    NSBundle *bundle = [[NSBundle alloc] initWithPath:hackBundlePath];
    NSString *path = [bundle pathForResource:@"HackData" ofType:@"plist"];

    NSFileManager *fileManager = [NSFileManager defaultManager];
    if ([fileManager fileExistsAtPath: path]) {
        modsDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
    }
    else {
        [modsDict setObject:FALSE forKey:@"test"];
        [modsDict setObject:FALSE forKey:@"test1"];
        [modsDict setObject:FALSE forKey:@"test2"];

        [modsDict writeToFile:[bundle bundlePath] atomically: TRUE];

    }

}

生成文件:

include theos/makefiles/common.mk

TWEAK_NAME = test
test_FILES = Tweak.xm ModsTableViewController.mm
test_FRAMEWORKS = Foundation UIKit CoreFoundation

include $(THEOS_MAKE_PATH)/tweak.mk

BUNDLE_NAME = testBundle
testBundle_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries


include $(THEOS)/makefiles/bundle.mk

捆绑包是在正确的位置创建的,但在启动应用程序后,似乎没有创建 plist 文件。所以我想我可以说问题应该出在writeToFile方法上或之前

4

1 回答 1

0

您正在尝试将 plist 写入 bundlepath,而不是给它一个文件名。

[modsDict writeToFile:[[bundle bundlePath] stringByAppendingPathComponent:@"filename.plist"] atomically: YES];

于 2014-07-26T02:34:42.343 回答