在我的iPhone應用程序,如何從文檔目錄中提取路徑組件直到我的文件名?
我想提取的路徑組件....
/Users/priyadarshanjoshi/Library/Application Support/iPhone Simulator/5.0/Applications/A2CD9285-62E9-4447-9945-5D8CE090FB3A/Documents/Wine_12.png
我想提取
/Documents/Wine_12.png
我寫這段代碼...
有沒有更簡單的方法來做同樣的事情?
NSString *[email protected]"";
BOOL append=NO;
for(NSString *get in [imagePath pathComponents])
{
if([get isEqualToString:@"Documents"])
{
append=YES;
}
if(append==YES)
{
relativePathImage1=[relativePathImage1 stringByAppendingPathComponent:get];
}
}
NSLog(@"relativePathImage1 %@",relativePathImage1);
永遠不要讓你的個人信息在SO ... :) – DShah 2012-02-02 08:43:33