0
NSFileManager *fm=[NSFileManager defaultManager];
NSString *pathToFile=[NSString stringWithFormat:@"%@/sells", [fm currentDirectoryPath]];
if ([fm fileExistsAtPath:pathToFile] == NO)
{
return NO;
}
else
{
if(content)
{
[content release];
}
content=[[NSMutableString alloc] initWithContentsOfFile:pathToFile encoding:NSUTF8StringEncoding error:nil];
}
return YES;
它在XCode中正常工作,但my.app總是返回NO(當然在其目錄中存在「sells」)。如何解決它?編譯的程序找不到文件
你知道的當前目錄運行應用程序是?如果這些文件在您的包中,那麼您需要獲取包路徑而不是當前目錄。 – trojanfoe
對,你幾乎不用iPhone上的currentDirectoryPath。它主要是因爲歇斯底里的原因。 –
即使NSString * pathToFile = [NSString stringWithString:@「sells」]; (文件與應用程序在同一目錄中)它返回否:( –