Use fopen function in iOS system and fopen function in ios system

Source: Internet
Author: User

Use fopen function in iOS system and fopen function in ios system

When openssl codec is used in the application these days, if the FILE cannot be obtained by opening the FILE with fopen, crash will be solved. The following is a record:


Because some code at the bottom layer of the application is written in C, you need to open a file to read data. NSURL is used when creating a file in Objective-C at the beginning, [[url absoluteString] UTF8String] is used for uploading to the C code. The fd obtained during fopen is-1 and the file is not opened.


When tracking the code, it is found that the NSURL points to the file path in the format of file: // xxxx, but if the NSString points to the file path is/file/xxxx, in UNIX file systems, the former cannot locate a file,Finally, you can use NSString to point to the file by modifying the method of creating and obtaining the file. You must never use NSURL.

Files placed under Document and tmp are not affected.


The above are the lessons learned to solve this problem. It took 30 minutes to discover the lessons of blood. Hope to help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.