
所以我尝试使用NSfileHandle的fileDescriptor:
– (NSfileHandle )readHandle:(DBError *)error
Returns a read-only file handle for the file. If the file is not
cached then the method will block until the file is downloaded.
ReturnsA file handle if the file can be read,or nil if an error occurred.
并作为文件传递*:
- (voID)loadDBfile:(DBfile *)dbfile{ DBError *dbError; NSfileHandle *fileHandle = [dbfile readHandle:&dbError]; if (fileHandle) { file *file = fileHandle.fileDescriptor; fseek(file,SEEK_END); // EXE_BAD_ACCESS here! // ... }} 但是,fseek行有一个EXE_BAD_ACCESS.
解决方法 fileDescriptor返回底层文件描述符,一个简单的整数,而不是一个file对象(包装文件描述符,但不是同一个东西).使用fdopen()从文件描述符中获取file对象: file *file = fdopen([filehandle fileDescriptor],"r"); // Create a read-only file object总结
以上是内存溢出为你收集整理的ios – 如何从NSFileHandle *获取文件*?全部内容,希望文章能够帮你解决ios – 如何从NSFileHandle *获取文件*?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)