일부 데이터를 저장하기 위해 plist 파일을 사용하는 조정을하려고합니다.
하지만 실행 중에 앱이 다운됩니다.mobilesubtrate tweak에서 번들 리소스 사용
Tweak.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
방법이나 그 전에 있어야한다고 생각합니다.
은'writeToFile는 : 원자 적'메소드 리턴 값을 갖는다. 저것 좀 봐주세요. 나는'setObject : forKey :'에'FALSE'를 전달하는 것이 100 % 확실하지 않다. – Nate