Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: None  |  size: 0.98 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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]];