問題描述
蘋果存儲指南的方式給我帶來了更多問題,因為我從 Documents 目錄維護的大部分數據(文件、數據庫和某種與應用程序相關的東西).最近我將一個二進制文件上傳到應用程序商店,它被拒絕了,蘋果向我提供了一份報告 根據這一點,我將更改我的代碼,如下所示
The way apple storage guidelines is creating more problem for me because most of the data i am maintaining from the Documents directory (files,dataBase and some kind of app related stuff).Recently i uploaded a binary file to the app store it was rejected and apple provided me a report according to this point i am going to change my code as a below
- (NSString *)applicationDocumentsDirectory {
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSURL *pathURL= [NSURL fileURLWithPath:documentPath];
[self addSkipBackupAttributeToItemAtURL:pathURL];
return documentPath;
}
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
我的問題:
1.我可以直接對文檔目錄使用 addSkipBackupAttributeToItemAtURL: 方法來禁止我在文檔目錄中的所有文件的 iCloud 備份.
1.can i use addSkipBackupAttributeToItemAtURL: method directly to the documents directory to privent the iCloud backup for my all files in the documents directory.
2.上面提到的代碼足以讓我的應用在應用商店中獲得批準,以防我的最后一個二進制文件由于不備份"屬性而被拒絕,因為我的文檔目錄中不包含不備份"屬性.
2.Above mentioned code is enough for my app to be approve in app store in case my last binary rejected due to "do not back up" attribute not included for my documents directory.
推薦答案
您應該能夠將此屬性設置為文件夾,以避免備份完整的文件夾.
You should be able to set this attribute to a folder in order to avoid backup of the complete folder.
但請注意,對完整的 Documents 文件夾執行此操作可能不是一個好方法.首先,這將造成您的應用程序沒有備份內容的情況,因此在手機恢復時應用程序將處于原始狀態.我也可以想象這不是蘋果想要的"方式,因此可能導致應用程序被拒絕(總是猜測).如果可能,我會在 Document 目錄中為您的非備份內容創建一個子文件夾,并將所有內容放在那里(如果您已經在商店中擁有此應用程序的版本,這可能需要一些遷移代碼).
Note however that it might noch be a good approach to do this to the complete Documents folder. First of all this will create a situation where you're app has no backed-up content thus on a restore of the phone the App will be in vanilla state. I could also imagine that this just is not the way "as Apple intended" and thus could lead to rejection of the app (always a guesswork). If possible, I would create a subfolder for your non-backed-up content in the Document directory and put everything there (this might need some migration code though if you already have a version of this app on the store).
請注意,存儲指南確實允許在 Documents 目錄中存儲用戶創建/不可重新創建的內容,您只需標記下載的內容等不能放入 Caches 目錄的內容(例如,如果用戶預計此內容可以離線使用).
Note that the storage guidelines do allow storage of user-created / non-recreatable content in the Documents directory and you only have to mark things like downloaded content etc. that you cannot put in the Caches directory (for example if the user expects this content to be available offline).
這篇關于從 iCloud 中的應用程序備份阻止的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!