Guest User

Untitled

a guest
May 3rd, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. How to extract a path components from documents directory till my file name?
  2. /Users/priyadarshanjoshi/Library/Application Support/iPhone Simulator/5.0/Applications/A2CD9285-62E9-4447-9945-5D8CE090FB3A/Documents/Wine_12.png
  3.  
  4. /Documents/Wine_12.png
  5.  
  6. NSString *relativePathImage1=@"";
  7. BOOL append=NO;
  8. for(NSString *get in [imagePath pathComponents])
  9. {
  10. if([get isEqualToString:@"Documents"])
  11. {
  12. append=YES;
  13. }
  14. if(append==YES)
  15. {
  16. relativePathImage1=[relativePathImage1 stringByAppendingPathComponent:get];
  17. }
  18. }
  19. NSLog(@"relativePathImage1 %@",relativePathImage1);
  20.  
  21. [strPath componentsSeparatedByString:@"Document"]
  22.  
  23. NSString *fullPath = // Get the path to your image
  24. NSString *pathWithNoFileName = [fullPath stringByDeletingLastPathComponent];
  25. NSString *myPath = [[pathWithNoFileName lastPathComponent] stringByAppendingPathComponent:[fullPath lastPathComponent]];
Advertisement
Add Comment
Please, Sign In to add comment