Skip to content

Instantly share code, notes, and snippets.

@neilinglis
Created June 27, 2013 12:44
Show Gist options
  • Save neilinglis/5876116 to your computer and use it in GitHub Desktop.
Save neilinglis/5876116 to your computer and use it in GitHub Desktop.
NSString *filePathInAssetsFolder = [assetURL.path stringByReplacingOccurrencesOfString:self.managedAssetFolderURL.path withString:@""];
NSString *resolution = @"1x";
//strip out the resolution from the filename and use it to populate the resolutions array
NSRange lastResolutionOccurrence = [filePathInAssetsFolder rangeOfString:@"@" options:NSBackwardsSearch]; //in case they have the resolution in filename more than once
if (lastResolutionOccurrence.location != NSNotFound) {
NSString *extension = [filePathInAssetsFolder pathExtension];
NSString *pathUpToResolutionString = [filePathInAssetsFolder substringToIndex:lastResolutionOccurrence.location];
NSRange extensionLocation = [filePathInAssetsFolder rangeOfString:@"." options:NSBackwardsSearch];
if (extensionLocation.location != NSNotFound){
NSRange resolutionRange = NSMakeRange(lastResolutionOccurrence.location, extensionLocation.location - lastResolutionOccurrence.location);
resolution = [filePathInAssetsFolder substringWithRange:resolutionRange];
}
filePathInAssetsFolder = [pathUpToResolutionString stringByAppendingPathExtension:extension];
}
NSLog(@"File path = %@", filePathInAssetsFolder);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment