Question

I have a program that will be grabbing a image from our server for the app, however we want to save the image onto the iOS app for caching purposes.

The url would be similar to this.

http://www.example.com/image/app_name/mypicture.png

I need a way to get the image name (mypicture) and the extension (.png) into 2 different strings to save it.

How would I accomplish this using a NSscanner?

Thanks

Was it helpful?

Solution

You wouldn't use a scanner. Use the NSURl method absoluteString to get the path and then use NSString methods pathExtension, stringByDeletingPathExtension and finally lastPathComponent to get the extension and name. You could also use the NSURL method resourceValuesForKeys:error: to get the name with the NSURLLocalizedNameKey.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top