objective c - Append logs into file -
i want make analogue of nslog() write file. have problem writing logs file. code below doesn't append logs file. overwrite it:
file * pfile; pfile = fopen ([filename utf8string],"a+"); va_list arglist; va_start(arglist, format); nsstring* formattedmessage = [[nsstring alloc] initwithformat: [nsstring stringwithformat:@"%@: %@", [date description], format] arguments:arglist]; va_end(arglist); nslog(@"%@", formattedmessage); fprintf(pfile, "%s\n", [formattedmessage utf8string]); fclose (pfile);
how fix it?
the problem seems '+' character after 'a' in fopen instruction. indicating want open new file in append-only mode. try taking out.
http://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm
Comments
Post a Comment