2013-08-18 62 views

回答

0

這應該工作:

NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 

    NSString *destination = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist", textfield.text]; 

    [fileData writeToFile:destination atomically:YES]; 
0
[self savePlist:@"Servers" fromArray:yourArray]; //or 
// [self savePlist:textField.text fromArray:yourArray]; 

#pragma mark - plist 
- (NSString *) getFilePathForPlist:(NSString *) plistName { 
    NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    return [[pathArray objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist",plistName]]; 
} 

-(void) savePlist:(NSString *)plistName fromArray:(NSMutableArray *)array { 
    [array writeToFile:[self getFilePathForPlist:plistName] atomically:YES]; 
} 
相關問題