Created
June 27, 2013 12:44
-
-
Save neilinglis/5876116 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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