I have some txt files that store some important data for my app. Due to its nature I want them to be in external text files. Currently i plan on reading them using a streamreader that reads the txt line by line. However, i don't know where to put my txt files, so i can access them in my streamreader which requires their path. Ive seen examples of using NSBundle.mainBundlepathforResource. However, I'm not really sure what a Bundle is or how to place my files there in the first place.
Asked
Active
Viewed 44 times
0
-
I think this is what you're looking for http://stackoverflow.com/questions/24097826/read-and-write-data-from-text-file – Jhorra Jun 08 '16 at 21:58
-
1@LeoDabus Why do you say "you can't"? The OP said nothing about writing to the files. – rmaddy Jun 08 '16 at 22:01
-
Don't you think the first thing you need to do is to read Apple Documentation on what NSBundle is before asking this question? Here: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/ – Armin Jun 08 '16 at 22:09
-
@Armin Yes i looked at the documentation, but that still does not tell me how to add pre-existing files to a Bundle or where to find the Bundle outside of code in the first place. – Praveen Jun 08 '16 at 22:27
1 Answers
0
You can use NSBundle. Here's another answer that shows how to create and use bundles: https://stackoverflow.com/a/23884501/1228075