この問題のために私のアプリケーションは拒否されました:
私のアプリケーションは、ブックマークなどを使用してSQLDBを使用する辞書です...
だから私はappDelegate.mのAppleドキュメントからこのコードをコピーしました:
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
しかし、このように使用されます:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:@"<myApplication>/Library/Caches"]];
}
しかし、この理由でクラッシュします:
アサーションに失敗しました:([[NSFileManager defaultManager] fileExistsAtPath:[URL path]])、function-[AppDelegate addSkipBackupAttributeToItemAtURL:]、file /iData/Development 2011 / My iPhone Project / APPNAME / APPNAME / AppDelegate.m、27行目。
その写真によると、これは私の拒絶の唯一の問題ですか?データベースを扱うのはこれが初めてだからです。
ありがとう 。~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
編集済み:
- (NSString *) getDBPath
{
NSInteger kValue = [[[NSUserDefaults standardUserDefaults] stringForKey:@"Bv"] intValue];
NSString *documentsDir = [[NSString alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
documentsDir = [paths objectAtIndex:0];
switch (kValue) {
case 0:
documentsDir = [NSString stringWithFormat:@"%@/eng-per.sqlite", documentsDir];
break;
case 1:
documentsDir = [NSString stringWithFormat:@"%@/eng-per.sqlite", documentsDir];
break;
case 2:
documentsDir = [NSString stringWithFormat:@"%@/per-eng.sqlite", documentsDir];
break;
}
return documentsDir
}
次に、アプリデリゲートでこれに変更しました。m:
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:dbClass.getDBPath]];
アプリがクラッシュすることなく正常にランチするようになりました