`
慭慭流觞
  • 浏览: 45582 次
  • 性别: Icon_minigender_1
  • 来自: 河南
社区版块
存档分类
最新评论

Why can't I save data to my application's bundle when running on the device?

    博客分类:
  • iOS
阅读更多

Q:  My application saves data to the application's bundle, which works fine in the iPhone Simulator. However, when I run on a device, my data cannot be saved. What's going on?

A: The different behaviors you are seeing are due to differences between the iPhone Simulator and the actual device. In the simulator, your application bundle is saved in a location that allows you full read/write access, so your code succeeds in writing and saving the preference data to the bundle. However, on the device, your application bundle cannot be modified. The File System Programming Guide contains information on the writeable locations in your application directory.

Your iPhone application's home directory contains a subdirectory for preferences (<Application_Home>/Library/Preferences). However, you should not create preferences files directly, but should instead use the NSUserDefaults or CFPreferences to get and set application preferences.

Alternately, you can save application specific data to the <Application_Home>/Documents subdirectory of your application's home directory. Use the NSFileManager URLsForDirectory:inDomains: method to get a URL to this directory.

Both of the above techniques also have the additional advantage that they will preserve the users data when the application is updated.

 
分享到:
评论

相关推荐

    Rational Data and Application Modeling Bundle

    IBM Rational Data and Application Modeling Bundle 方便地将两种类型的工具打包到一种产品中,为负责开发数据和应用程序的开发人员提供了一种获取所需架构功能的简便方法,全部基于 Eclipse 并具有与 IBM Rational...

    Data Analytics and Python Programming 2 Bundle Manuscript

    Data Analytics: Practical Data Analysis and Statistical Guide to Transform and Evolve Any Business, Leveraging the power of Data Analytics, Data Science, and Predictive Analytics for Beginners ...

    Data.Analytics.and.Linux.Operating.System.1541352149.epub

    Data Analytics: Practical Data Analysis and Statistical Guide to Transform and Evolve Any Business, Leveraging the power of Data Analytics, Data Science, and Predictive Analytics for Beginners ...

    android sdk 自带 实例(samples)

    An application that demonstrates how to create a live wallpaper and bundle it in an application that users can install on their devices. Lunar Lander A classic Lunar Lander game. Multiple ...

    XDA成员开发出Carrier IQ检测程序(Android)

    I have decided to put the key to unlock removal features on any device on the market. It should be listed under package com.treve.loggingkey Its called Logging TestApp Pro Key. Just install the apk ...

    Xcode_Build_Setting_Reference

    It is important to select the appropriate architecture to ensure compatibility with the device on which the app will run. ##### DYLIB_COMPATIBILITY_VERSION (Compatibility Version) This setting ...

    bundletool-all-1.7.0.jar

    Verify code transparency inside an Android App Bundle, APK files or an application installed on a connected device. Read more about the App Bundle format and Bundletool's usage at g.co/androidapp...

    Scala: Guide for Data Science Professionals

    Scala is especially good for analyzing large sets of data as the scale of the task doesn't have any significant impact on performance. Scala's powerful functional libraries can interact with databases...

    Git-2.21.0-64-bit.zip

    the on-disk index file, breaking t7519 tests occasionally, which has been corrected. * Update to Unicode 12.1 width table. * The command line to invoke a "git cat-file" command from inside "git...

    电子书版权移除工具eBook DRM Removal Bundle 4.15

    user can view non-drm ebook on iPad, NOOK, Sony Reader or other device without limitation, convert ebook to pdf/doc format in Calibre to print and share ebook with friends. Key Features - Drag Drop ...

    wxPython 2.8 Application Development Cookbook (含源码)

    Set up the wx main frame by adding your own Frame class to the application Create two stage widgets by using a three step process Set up an event handler, customize, receive and handle events by ...

    Bundle Adjustment Method using Sparse BFGS Solution

    This letter introduces an efficient bundle adjustment (BA) method based on the sparse Broyden-Fletcher-Goldfarb-Shanno (sparse BFGS, sBFGS) solution, which efficiently estimates camera poses and 3-D ...

    Stream Processing with Apache Flink

    With Early Release ebooks, you get books in their earliest form—the author's raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official ...

    Application数据共享Android

    现在,我们可以在任何Activity、Service等组件中通过`MyApplication.getInstance().getSharedData()`来获取共享数据,或者通过`MyApplication.getInstance().setSharedData(data)`来设置共享数据。例如,在一个...

    PoolManager 5.5.2 游戏性能优化插件(最新完整版)

    Save at least 25% when you bundle! PoolManager, the original and best instance pooling solution for Unity, manages instances more efficiently to increase performance, organize the scene hierachy and...

Global site tag (gtag.js) - Google Analytics