omo escrever um arquivo .csv a partir da funçã

Hey amigos, eu tenho todos os detalhes de contatos do meu iphone usando esta função ..

    -(void)collectContacts
{
    ABAddressBookRef addressBook = ABAddressBookCreate();
    CFArrayRef people  = ABAddressBookCopyArrayOfAllPeople(addressBook);
    //NSLog(@" the Name %@%",people);
    for(int i = 0;i<ABAddressBookGetPersonCount(addressBook);i++)
    {
        ABRecordRef ref = CFArrayGetValueAtIndex(people, i);
        // Get First name, Last name, Prefix, Suffix, Job title 
        NSString *firstName = (NSString *)ABRecordCopyValue(ref,kABPersonFirstNameProperty);
        NSString *lastName = (NSString *)ABRecordCopyValue(ref,kABPersonLastNameProperty);
        NSString *prefix = (NSString *)ABRecordCopyValue(ref,kABPersonPrefixProperty);
        NSString *suffix = (NSString *)ABRecordCopyValue(ref,kABPersonSuffixProperty);
        NSString *jobTitle = (NSString *)ABRecordCopyValue(ref,kABPersonJobTitleProperty);
        NSLog(@" the phoneType %@%",firstName);
        NSLog(@" the phoneType %@%",lastName);

        ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
        for(CFIndex j = 0; j < ABMultiValueGetCount(phones); j++)
        {       
            CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phones, j);   
            NSString *phoneLabel =(NSString*) ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex(phones, j));
            NSString *phoneNumber = (NSString *)phoneNumberRef;
            NSLog(@" the phoneType %@%",phoneLabel);
            NSLog(@" the phoneNumber %@%",phoneNumber);
        }

        CFStringRef address;
        CFStringRef label;
        ABMutableMultiValueRef multi = ABRecordCopyValue(ref, kABPersonAddressProperty);    
        for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++) 
        {           
            label = ABMultiValueCopyLabelAtIndex(multi, i);
            CFStringRef readableLabel = ABAddressBookCopyLocalizedLabel(label);
            NSLog(@" Lable %@%",readableLabel);
            address = ABMultiValueCopyValueAtIndex(multi, i);
            NSLog(@" Address %@%",address);
            CFRelease(address);
            CFRelease(label);
        } 

        ABMultiValueRef emails = ABRecordCopyValue(ref, kABPersonEmailProperty);
        for(CFIndex idx = 0; idx < ABMultiValueGetCount(emails); idx++)
        {
            CFStringRef emailRef = ABMultiValueCopyValueAtIndex(emails, idx);
            NSStr,ing *strLbl = (NSString*) ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex (emails, idx));
            NSLog(@" Email Lable %@%",strLbl);
            NSString *strEmail_old = (NSString*)emailRef;
            NSLog(@" Email-Id %@%",strEmail_old);
            //[[strEmail_old componentsJoinedByString:@","] writeToFile:@"components.csv" atomically:YES encoding:NSUTF8StringEncoding error:NULL];
        }
    }
    //[[ContactsText componentsJoinedByString:@","] writeToFile:@"components.csv" atomically:YES encoding:NSUTF8StringEncoding error:NULL];
//  NSLog(@" Data in the .CSV file = %@%",ContactsText);
}
'

Agora eu quero criar um arquivo .csv a partir desta saída da função .. e estou recebendo todos os dados no NSLog. Eu quero escrever arquivo .csv a partir desses dados. Alguém pode me ajudar nisso? Os dados são adequados, mas o arquivo .csv não será gravado ... Obrigado

questionAnswers(3)

yourAnswerToTheQuestion