Quote:
Originally Posted by wassupdoc
I am loading images from the iphone camera roll and I need to get the specific image number of each. I have been able to get the path to each asset as follows:
assets-library://asset/asset.JPG?id=1000000035&ext=JPG
Now how would i get just the id number and strip out the leading 1s and 0s. I am assuming as my photo collection grows that id may contain 3 or 4 useful digits, so I want to make sure I remove only the 0s.
Thanks for the help
|
NSString has a bunch of useful methods for string parsing.
rangeOfString: is where you should start.
If your path is in a string pathString, you could use code like this:
NSRange idRange = [pathString rangeOfString: @"id="];
Then you could write a while loop that skipped past a beginning "1" and some number of leading zeros.
Then you would need to calculate a range that started just after the first non-zero digit and went to the end of the string, and search the string for an "&" using rangeOfString

ptions:range:locale: (That method lets you pass in a range to search inside the string. Pass zero for options, and nil for locale, since you don't need those features.) You could then calculate the range for just the digits you want, and use substringWithRange to extract the digits you want.