IOS 其他

下面的方法都是在Appdelegate.m中

 
 
 

- (void)redirectNSLogToDocumentFolder{

    
    NSString *fileName =[NSStringstringWithFormat:@"%@.log",[NSDatedate]]; 
    NSString *logFilePath = [DOCUMENT_PATHstringByAppendingPathComponent:fileName]; 
    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);

- (BOOL)applicationemoticon_unhappyUIApplication *)application didFinishLaunchingWithOptionsemoticon_unhappyNSDictionary *)launchOptions
{
    制定真机调试保存日志文件
    UIDevice *device =[UIDevicecurrentDevice];
    
    if (![[device model] isEqualToString:@"iPad Simulator"]) {
        [selfredirectNSLogToDocumentFolder];
    }

 
 
 

项目配置共享文件

 

您可以通过如下步骤来让应用程序支持文件共享:在应用程序的Info.plist文件中添加UIFileSharingEnabled键,并将键值设置为YES。将您希望共享的文件放在应用程序的Documents目录。一旦设备插入到用户计算机,iTunes 9.1就会在选中设备的Apps标签中显示一个File Sharing区域。此后,用户就可以向该目录添加文件或者将文件移动到桌面计算机中。如果应用程序支持文件共享,当文件添加到Documents目录后,应用程序应该能够识别并做出适当响应。例如说,应用程序可以将新文件的内容显示界面上。请不要向用户展现目录的文件列表并询问他们希望对文件执行什么操作。

 
 
 

然后通过真机调试,通过itunes查看共享文件

原文地址:https://www.cnblogs.com/ziyeSky/p/4230721.html