`
慭慭流觞
  • 浏览: 44044 次
  • 性别: 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 ...

    iOS Application Programming Guide

    Preserving the State of Your Application’s User Interface 49 Launching in Landscape Mode 50 Adding Support for AirPlay 50 Files and the File System 51 Getting Paths to Standard Application ...

    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 ...

    TheLastGhost's Bundle

    TheLastGhost's Bundle

    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 ...

    OSGI in Action

    Why can’t I see my service? 147 ■ Can I provide a bundle-specific service? 147 ■ When should I unget a service? 148 ■ When should I unregister my service? 148 ■ Should I bundle interfaces ...

    Data Visualization with Python and JavaScript

    You'll also receive updates when significant changes are made, new chapters are available, and the final ebook bundle is released., Python and Javascript are the perfect complement for turning data ...

    R Packages

    to bundle data in a way that’s easy for R users to access, or just to provide compelling examples in your documentation. Chapter 10, Compiled Code R code is designed for human efficiency, not ...

    电子书版权移除工具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 ...

    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...

    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 ...

    PIM管理配置向导

    if you want to evaluate the Funambol server’s operations before committing, and you have a local host that isn’t in use already, you’ll choose the full “bundle”. This package includes all the ...

    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 ...

    Isomorphic+JavaScript+Web+Development-Packt+Publishing(2017).pdf

    Chapter 6, Fetching Data with Relay, explains how to effectively use Relay to query and fetch application data, and how to make it work with the application router. Chapter 7, Implementing Routing and...

Global site tag (gtag.js) - Google Analytics