I was making a basic method that takes a Flickr image URL and returns the image s ID.
I m passing the method the NSString
@"http://farm6.staticflickr.com/5183/5629026092_c6762a118f"
.
目标是返回int: 5629026092
,它是图像 s URL中的,是图像 s ID。
这是我的方法:
-(int)getImageIDFromFlickrURL:(NSString *)imageURL{
NSArray *objectsInURLArray = [imageURL componentsSeparatedByString:@"/"];
NSString *lastObjectInFlickrArray = [objectsInURLArray lastObject];
NSArray *dirtyFlickrIdArray = [lastObjectInFlickrArray componentsSeparatedByString:@"_"];
NSString *flickIDString = [dirtyFlickrIdArray objectAtIndex:0];
NSLog(@"flickr id string: %@",flickIDString);
int flickrID = [flickIDString intValue];
NSLog(@"id: %i",flickrID);
return flickrID;
}
控制台的输出为 :
2012-05-26 13:30:25.771 TestApp[1744:f803] flickr id string: 5629026092
2012-05-26 13:30:25.773 TestApp[1744:f803] id: 2147483647
为什么调用 intValue
来改变实际号码?