I’m working with Xcode 4 and I’d like my iphone 4 application to append a line to a file every time I run a test. Is there any fast way to do this? If so, where exactly am I allowed to write inside the iphone directory hierarchy?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t write inside the bundle of the iPhone application because that would break encryption. You can write in the
Documentsdirectory, or somewhere under<apphome>/Library.Since
Documentsmay become visible for the iTunes user if you addUIFileSharingEnabledto yourInfo.plist, and this is a file private to the application, adding the file underLibraryis better. Not that it matters much during testing. Apple documents related to this: Technical Q&A QA1699: Storing Private Data, A Few Important Application Directories.You can use this code in an iPhone application to append text to a file: