2010-01-15 3 views
0

J'essaie de sauvegarder les fichiers kABFirstNamePropert, kABLastNameProperty et kABAddressProperty tous sauvegardés dans un tableau pour être rappelés plus tard, je ne comprends pas, quelqu'un peut-il me prêter main-forte ou me pointer dans le bon sens? direction? Merci. Je suis un super NOOb à ce sujet.Enregistrement des données addressbookUI dans un tableau

Pour la désignation des chaînes:

// setting the first name 
firstName.text = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); 

// setting the last name 
lastName.text = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); 

Pour régler la addressLabel:

NSString *address; 
    address = [NSString stringWithFormat:@"%@, %@, %@, %@ %@", 
       [theDict objectForKey:(NSString *)kABPersonAddressStreetKey], 
       [theDict objectForKey:(NSString *)kABPersonAddressCityKey], 
       [theDict objectForKey:(NSString *)kABPersonAddressStateKey], 
       [theDict objectForKey:(NSString *)kABPersonAddressZIPKey], 
       [theDict objectForKey:(NSString *)kABPersonAddressCountryKey]]; 

    self.addressLabel.text = address; 

Enregistrement du tableau: Ce que je qui ne fonctionne pas. ; (

- (IBAction)saveData { 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *recipient = [NSString stringWithFormat:@"%@/arraySaveFile", documentsDirectory]; 

    NSMutableArray *array = [[NSMutableArray alloc] init]; 
    [array addObject:firstName]; 
    [array addObject:lastName]; 
    [array addObject:addressLabel]; 

    [array writeToFile:recipient atomically:NO]; 

} 

Répondre

1

Ce:

[array addObject:firstName]; 

nécessaire pour être:

[array addObject:firstName.text]; 

Merci à tous

.
Questions connexes