jjzjj

Filepath

全部标签

ios - writeToFile 在 iOS 7 上工作而不在 iOS 6 上工作

我遇到了一个问题,但找不到任何相关信息。我得到了一些代码,可以使用iOS在Documents文件夹中写入文件。检查了Apple文档,我想把它放在下一次发布时可用的地方。这是我使用的代码:-(void)writeToTextFile:(NSString*)logMessageinFile:(NSString*)fileName{//getthedocumentsdirectory:NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString*docu

ios - 在 Today 扩展中加载文件

我一直在尝试创建一个需要访问文档目录中的.plist文件的Today扩展。我已经为应用程序和扩展程序设置了应用程序组。虽然我看过NSUserDefaults的示例,但我找不到任何用于访问文件的内容。我试过像这样访问文件(在应用程序本身中有效)letpaths=NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)letdocumentsDirectory=paths[0]asStringletfilePath="\(documentsDirectory)/config.plist"ifNS

ios - Objective-C 为 PDF 创建映射文件

我正在创建一个这样的文件:NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString*documentsDirectory=[pathsobjectAtIndex:0];filePath=[NSStringstringWithFormat:@"%@/%@",documentsDirectory,PDFFile];if(![[NSFileManagerdefaultManager]fileExistsAtPath:filePath]){[[NSFi

iphone - 如何在 objective-c iphone中将内容写入文本文件

我正在用iPhone编写内容。我使用了这段代码NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString*filePath=[[pathsobjectAtIndex:0]stringByAppendingPathComponent:@"data.txt"];NSString*temp=[[NSStringalloc]initWithString:@"mynameisgaurav"];[tempwriteToFile:filePathatomica

ios - RTF 中的 NSAttributedString 仅适用于 iOS 8,不适用于 iOS 7

我正在尝试使用以下代码在UITextView中加载RTF文件:NSURL*filePath=[[NSBundlemainBundle]URLForResource:_fileNamewithExtension:@"rtf"];NSAttributedString*stringWithRTFAttributes=[[NSAttributedStringalloc]initWithFileURL:filePathoptions:@{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType}documentAttributes:nilerro

ios - 如何获取 ALAsset 对象的物理路径

有没有办法将下面调用返回的资源url转为设备上的物理路径?NSURL*assetUrl=[_selectedAssetdefaultRepresentation]url]; 最佳答案 没有办法。(即使你有文件的路径,你的应用程序也无法读取文件,因为沙盒。)获取Assets原始数据的唯一方法是ALAssetRepresentation中的getBytes:fromOffset:length:error:。 关于ios-如何获取ALAsset对象的物理路径,我们在StackOverflow上

ios - 在本地保存 NSURL 的 PDF - 检索

你好,我如何从NSDictionary本地检索NSUrl的PDF。我这样保存:NSData*pdfData=[[NSDataalloc]initWithContentsOfURL:[NSURLURLWithString:@"http://www.example.com/info.pdf"]];//StoretheDatalocallyasPDFFileNSString*resourceDocPath=[[NSStringalloc]initWithString:[[[[NSBundlemainBundle]resourcePath]stringByDeletingLastPathCom

ios - 将大数据转换为 NSData

我正在存储一个大小超过1GB的视频文件并存储到homeDirectory中。我正在尝试按如下方式转换为NSData对象NSData*videoData=[[NSDataalloc]initWithContentsOfFile:filePath];但在这里我得到的视频数据为零。当我尝试播放500MB的视频时,它工作正常。转换为NSData时是否有大小限制? 最佳答案 尝试使用这个(需要iOS5.0或更高版本):NSError*error=nil;NSData*data=[[NSDataalloc]initWithContentsOfF

ios - NSBundle pathForResource : returns nil

我正在尝试使用以下代码从iOS上的Xcode中的支持文件文件夹访问.txt文件:NSString*filePath=@"filename.txt";NSLog(@"Filepath:%@",filePath);NSString*fileRoot=[[NSBundlemainBundle]pathForResource:filePathofType:@"txt"];NSLog(@"Fileroot:%@",fileRoot);第一个NSLog打印出我期望它打印的内容,但最后一个NSLog总是简单地打印Fileroot:(null)在(尝试)将文件读入内存后访问文件中的文本也只会给我一个(

iphone - 在 iPad 上播放声音,使用 AudioToolbox

我发现了一个使用工具箱播放声音的功能,创建它的人获得了荣誉:-(SystemSoundID)createSoundID:(NSString*)name{NSString*path=[NSStringstringWithFormat:@"%@/%@",[[NSBundlemainBundle]resourcePath],name];NSURL*filePath=[NSURLfileURLWithPath:pathisDirectory:NO];SystemSoundIDsoundID;AudioServicesCreateSystemSoundID((CFURLRef)filePath,