title: How to convert the NSMutableArray to CSV file on iPhone?
body: <p>I am writing an iPhone application, which contains a function. It can convert the NSMutableArray to a CSV file. However, I don't know how to do. Can anyone help me to do this? Thank you very much.</p>
  
  <p>//  ------ Update -----</p>
  
  <p>Thank you for everyone reply.</p>
  
  <p>Actually, the array contains the objects of the elements, but I can convent it all to the array like the following (I guess it is more easy to do this).</p>
  
  <p>The array is NSMutableArray *csvArray and the array contains data, like the following example.</p>
  
  <pre><code>csvArray[0] = First Name
  csvArray[1] = Last Name
  csvArray[2] = Phone
  csvArray[3] = Tom
  csvArray[4] = Chan
  csvArray[5] = 123
  csvArray[6] = Peter
  csvArray[7] = Wong
  csvArray[8] = 456
  csvArray[9] = Mary's
  csvArray[10] = Cho"w
  csvArray[11] = 789...
  </code></pre>
  
  <p>There are 3 tabs in the begin of the array, which is first name, last name and the phone. For the data, it also contains the " and , symbol. Therefore, I cannot just cut the array by the ',' symbol. </p>
  
  <p>The format I would like to output is the following</p>
  
  <pre><code>//---------------------------
  
  First Name, Last Name, Phone  // &lt;- it have the \r\n between each row of data
  Tom, Chan, 123
  Peter, Wong, 456
  Mary's, Cho"w, 789 ...
  
  //---------------------------
  </code></pre>