Convert NSMutableArray to string and back
Posted
by Friendlydeveloper
on Stack Overflow
See other posts from Stack Overflow
or by Friendlydeveloper
Published on 2010-03-30T02:11:24Z
Indexed on
2010/03/30
2:13 UTC
Read the original article
Hit count: 957
Hello,
in my current project I'm facing the following problem:
The app needs to exchange data with my server, which are stored inside a NSMutableArray on the iPhone. The array holds NSString, NSData and CGPoint values. Now, I thought the easiest way to achieve this, was to convert the array into a properly formatted string, send it to my server and store it inside some mySQL database. At this point I'd like to request my data from my server, receive the string, which represents contents of my array and then actually convert it back into a NSMutablArray.
So far, I tried something like this:
NSString *myArrayString = [myArray description];
Now I send this string to my server and store it inside my mySQL database. That part works really well.
However, when I receive the string from my server, I have trouble converting it back into a NSMutableArray.
Is there a method, which can easily convert array description back into an array? Unfortunately I couldn't find anything on that so far. Maybe my way of "serializing" the array is wrong right from the start and there is a smarter way to do this.
Any help appreciated. Thanks in advance.
© Stack Overflow or respective owner