saving into .txt file

Discussion in 'iOS Programming' started by HarryWorksInc, Mar 4, 2010.

  1. HarryWorksInc macrumors regular

    Joined:
    Feb 21, 2010
    #1
    Hey, does anyone know how to save into a .txt file? I know how to read them just need to write.
     
  2. fernandovalente macrumors 6502

    fernandovalente

    Joined:
    Aug 29, 2008
    Location:
    Third world **** hole, I mean, Brazil
    #2

    Code:
    NSError *error;
    	NSData *data = [myString dataUsingEncoding:NSUTF8StringEncoding];
    	BOOL success = [data writeToFile:PATHTOFILE options:0 error:&error];
    	if(!success){
    		NSAlert *a = [NSAlert alertWithError:error];
    		[a runModal];
    	}
    Hope that helps :)
     
  3. HarryWorksInc thread starter macrumors regular

    Joined:
    Feb 21, 2010

Share This Page