How to append string in local resource txt file for iOS sdk

后端 未结 3 1412
温柔的废话
温柔的废话 2020-12-14 22:48

I have been trying to append strings to a local resource file but I am having trouble finding a solution. I am trying to create a log file for all the function call in my ap

3条回答
  •  情书的邮戳
    2020-12-14 23:30

    This way you can do this..

    + (void)WriteLogWithString:(NSString *)log
    {
    
            if(log != nil){
    
                NSString *locationFilePath = [self getLogFilePath];//access the path of file
    
                FILE *fp = fopen([locationFilePath UTF8String], "a");
    
                fprintf(fp,"%s\n", [log UTF8String]);
    
                fclose(fp);
            }
    
    }
    

提交回复
热议问题