如何给文件设置do not back up属性。

转自:http://www.cocoachina.com/bbs/read.php?tid=85169


app产生的文件,比如下载的电子书啊什么的,应该放到cache目录下,但是如果设备的内存满了会自动清除cache下的文件,而且不确定在app升级更新后cache目录下的文件是否能被保留,所以还是应该放在documents目录下,然后给该新生成的文件设置一个do not back up属性就行了



#include <sys/xattr.h>
- (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;
}


下面是原文引用:

We found that your app does not follow the iOS Data Storage Guidelines, which is not in compliance with the App Store Review Guidelines.


In particular, we found book download (data) is not cached appropriately.


The iOS Data Storage Guidelines specify:


"1. Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the /Documents directory and will be automatically backed up by iCloud.


2. Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.


3. Data that is used only temporarily should be stored in the /tmp directory. Although these files are not backed up to iCloud, remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device.


4. Use the "do not back up" attribute for specifying files that should remain on device, even in low storage situations. Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory. These files will not be purged and will not be included in the user's iCloud or iTunes backup. Because these files do use on-device storage space, your app is responsible for monitoring and purging these files periodically."


For example, only content that the user creates using your app, e.g., documents, new files, edits, etc., may be stored in the /Documents directory - and backed up by iCloud. 


Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.


Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For more information, please see Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?.


It would be appropriate to revise your app to meet the requirements of the iOS Data Storage Guidelines. 


For discrete code-level questions, you may wish to consult with Apple Developer Technical Support. Please be sure to include any symbolicated crash logs, screenshots, or steps to reproduce the issues when you submit your request. For information on how to symbolicate and read a crash log, please see Tech Note TN2151 Understanding and Analyzing iPhone OS Application Crash Reports.

内容概要:本文深入探讨了Kotlin语言在函数式编程和跨平台开发方面的特性和优势,结合详细的代码案例,展示了Kotlin的核心技巧和应用场景。文章首先介绍了高阶函数和Lambda表达式的使用,解释了它们如何简化集合操作和回调函数处理。接着,详细讲解了Kotlin Multiplatform(KMP)的实现方式,包括共享模块的创建和平台特定模块的配置,展示了如何通过共享业务逻辑代码提高开发效率。最后,文章总结了Kotlin在Android开发、跨平台移动开发、后端开发和Web开发中的应用场景,并展望了其未来发展趋势,指出Kotlin将继续在函数式编程和跨平台开发领域不断完善和发展。; 适合人群:对函数式编程和跨平台开发感兴趣的开发者,尤其是有一定编程基础的Kotlin初学者和中级开发者。; 使用场景及目标:①理解Kotlin中高阶函数和Lambda表达式的使用方法及其在实际开发中的应用场景;②掌握Kotlin Multiplatform的实现方式,能够在多个平台上共享业务逻辑代码,提高开发效率;③了解Kotlin在不同开发领域的应用场景,为选择合适的技术栈提供参考。; 其他说明:本文不仅提供了理论知识,还结合了大量代码案例,帮助读者更好地理解和实践Kotlin的函数式编程特性和跨平台开发能力。建议读者在学习过程中动手实践代码案例,以加深理解和掌握。
### APB Back-to-Back Transaction Implementation and Issues in IT Systems In the context of financial transactions, particularly within enterprise resource planning (ERP) systems or specialized accounting software, implementing a back-to-back transaction involves creating two related but separate transactions that mirror each other. For instance, when an organization acts as both buyer and seller between itself and another entity. The specific mention regarding `.pak` files under `/saved` directory does not directly relate to APB back-to-back transactions[^1]. However, this could imply potential issues with system updates or patches affecting underlying business logic processing these types of transactions. Common challenges encountered during implementation include ensuring data integrity across mirrored entries, maintaining accurate audit trails, synchronizing timing differences between counterparties' records, handling currency conversions accurately where applicable, and managing tax implications properly. To mitigate risks associated with such implementations: - Thoroughly test all scenarios before going live. - Ensure robust exception-handling mechanisms are in place. - Regularly reconcile accounts involved in back-to-back deals. - Implement strict change control processes over relevant modules. For coding examples demonstrating basic concepts around mirroring transactions while preserving referential integrity one might consider pseudo-code like below which would need adaptation based on actual platform specifics used: ```sql BEGIN TRANSACTION; INSERT INTO SalesOrder (CustomerID, ProductCode, Quantity, Price) VALUES (@customerA_ID, @product_code, @quantity, @price); INSERT INTO PurchaseOrder (SupplierID, ProductCode, Quantity, CostPrice) VALUES (@supplierB_ID, @product_code, @quantity, @cost_price); COMMIT; ``` --related questions-- 1. What measures can be taken to ensure synchronization accuracy in cross-border back-to-back trades? 2. How should exceptions arising from discrepancies in back-to-back transactions be handled programmatically? 3. Can you provide guidance on setting up automated reconciliation checks for ongoing monitoring of back-to-back operations? 4. In what ways do regulatory requirements impact the design choices made for implementing back-to-back functionality?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值