Object c++ および Xcode 5 で記述されたコードに問題があります。
NSLog(@"%@",pathToFile);
NSString *outputFileName = [NSTemporaryDirectory() stringByAppendingPathComponent:@"output.txt"];
FILE* fileo = fopen([outputFileName UTF8String], "w");
if (fileo) fclose(fileo);
fileo = fopen([outputFileName UTF8String], "a");
if (!fileo) { perror("fopen"); NSLog(@" Wrong"); } else { NSLog(@"Nothing Wrong"); }
//Open the PDF source file:
// FILE* filei = fopen("c:\\pdf\\somepdf.pdf", "rb");
FILE* filei = fopen([pathToFile UTF8String], "rb");
if (!filei) { perror("fopen"); NSLog(@" Wrong"); } else { NSLog(@"Nothing Wrong"); }
if (filei && fileo)
{
問題は filei が毎回 Nil であり、理由がわからないことです。問題はpathtoFileだと思います:それは:pathToFileです
__NSCFString * @"file:///private/var/mobile/Applications/3D02CBE0-6A8E-4709-B6EF-B6793E19F4F4/Documents/Inbox/Published_071032-8.pdf"
0x145c53e0
このコードはシミュレーターではうまく機能しますが、iPhone では機能しません! 誰かが何が悪いのか考えていますか?
作業ディレクトリかもしれませんが、xcode 5 で変更する方法はありません。