-2

I am developing a guest list(NSMutableArray) and I would like to know If can I create and save this Array in any kind of external file such as .txt .pdf (or another extension)?

Any ideas for do this??

Thanks a lot.

  • Xcode is a development tool, it is not your run time environment. This question has nothing to do with Xcode... but it does have to do with Objective C. – mah Apr 23 '14 at 21:08
  • sounds like a great opportunity to edit the question to change the tags to be more relevant, @Mah ! – Michael Dautermann Apr 23 '14 at 21:09
  • @MichaelDautermann I agree but I don't like editing people's posts before they've had a chance to understand the issue. – mah Apr 23 '14 at 21:18
  • possible duplicate of [Writing array contents to a file](http://stackoverflow.com/questions/14328978/writing-array-contents-to-a-file) and http://stackoverflow.com/questions/8003244/writing-a-nsarray-to-file – rmaddy Apr 23 '14 at 21:24
  • Please note that as you enter your question into SO, you will be shown possibly related questions. Always check those before actually posting your question. – rmaddy Apr 23 '14 at 21:25

1 Answers1

0

NSArray (which is what NSMutableArray derives from) has a "writeToURL:atomically:" method, which takes a file URL.

Now, if your array contains ONLY objects of the Objective-C types NSString, NSData, NSDate, NSNumber, NSArray or NSDictionary, you should be okay. If you have some custom objects, you'll need to write archiving / unarchiving coder methods which will allow those custom object's data to be written out to a file and read from a file.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Thanks a lot, I am new developing with Objective C and I didn't know if I could do it, do you have any example where I can see the code? – user3355990 Apr 23 '14 at 23:53
  • [This related (or potentially even duplicate](http://stackoverflow.com/a/19595293/981049)) question has the answer (and code example) you need. – Michael Dautermann Apr 24 '14 at 00:09