Possible Duplicate:
Convert NSArray to NSString in Objective-C
I have an array of an NSArray myArray, here is the content:
(
"<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246",
"<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324",
"<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367"
)
I used the code below to assign to an NSString myString:
NSString *myString = [myArray description];
And the out put is still as expected:
(
"<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246",
"<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324",
"<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367"
)
Now, say I want to convert myString back to an array named newArray, I used this:
NSArray *newArray = [[NSArray alloc]init];
newArray = [myString componentsSeparatedByString:@","];
But the content of the newArray is now different:
(
"(
\"<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246\"",
"
\"<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324\"",
"
\"<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367\""
)"
)
Any idea what I need to do to fix this?
There are two methods
Use
NSString *myString = [myArray componentsJoinedByString:@","]; //instead of [myArray description];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With