views:

93

answers:

1

Hi all,

i've a class (downloaded from internet) that read a value of a file in this way (and after split the file):

NSArray* array = [fileContents  componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

where fileContents is my fullpathoffile.

in which way i must write my string? i'm trying with this:

    NSString *data = [NSString stringWithFormat:@"%@,%@""\n", latitudine.text, longitudine.text];
    NSFileHandle *handle;
    handle = [NSFileHandle fileHandleForWritingAtPath: [self dataFilePath] ];
    [handle truncateFileAtOffset:[handle seekToEndOfFile]];
    [handle writeData:[data dataUsingEncoding:NSUTF8StringEncoding]];   

i'm going crazy :D Any helpS?!?

A: 

i've solve in this way:

    NSString *data = somethingblablabla ;
    NSData *myData = [data dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSFileHandle *writeData = [NSFileHandle fileHandleForWritingAtPath:[self dataPath]];
    [writeData truncateFileAtOffset:[writeData seekToEndOfFile]];
    [writeData writeData:myData];
zebra