如何fopen()函数在iPhone? [英] How to fopen() on the iPhone?

查看:138
本文介绍了如何fopen()函数在iPhone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iPhone SDK文档要求fopen()函数是文件访问支持的方法,但我不能让它返回的文件句柄。我访问包含在我的项目目录。我已经试过的fopen文件名,目录/文件名,./文件名,./目录/文件名,/目录/文件名全部用一个空指针返回。有些人使用它,没有问题的报告,所以我敢肯定这是简单的东西!

The iPhone SDK docs claim fopen() is a supported method of file access but I am unable to get it to return a FILE handle. I am accessing a directory which is included in my project. I have tried fopen "filename","dir/filename","./filename","./dir/filename","/dir/filename" all returning with a null pointer. Some people report using it with no issue so I am sure it is something simple!

推荐答案

如果你想你的应用程序包中访问一个文件,你需要得到完整路径: [一个NSBundle mainBundle] pathForResource:FILENAME ofType:FILEEXTENSION]

if you're trying to access a file within your application bundle, you need to get the full path to it: [[NSBundle mainBundle] pathForResource: FILENAME ofType: FILEEXTENSION]

这将返回一个NSString,你可以拉出来UTF8字符串和传递给fopen。

This returns an NSString, which you can pull a UTF8String out of and pass to fopen.

这篇关于如何fopen()函数在iPhone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆