ALAsset URLs have changed from iOS 4.3 to 5.0? - objective-c

I've got an app where I'm taking pictures and storing them to the camera roll. I save the resultant ALAsset's URL so I can reload those specific images again later.
This seemed to be working fine until I upgraded to iOS 5.0.
Now, when I try to load the asset I'm always getting nil back.
I've enumerated the entire camera roll, checking the URLs of the images in there, and indeed the URLs seem to be different.
ie., I was able to save (and reload) an asset with URL: 'assets-library://asset/asset.JPG?id=1000001124&ext=JPG'. But, now it no longer exists. In fact, all the asset URLs are longer now, such as: 'assets-library://asset/asset.JPG?id=6BDB93FD-B94C-4F77-9ABD-26F34F06B429&ext=JPG' (perhaps those are now more unique?)
Anyway, has anyone else seen this? Am I missing something? Are all my old saved files now useless? Is there any way to map from the old URL to the new URL?
Should I be taking a different approach? I don't want to release this and then find out that the URLs have all been changed on me (and my users) again...
Thoughts?

Apple did rewrite the whole Photo-Library for iOS 5. Its now based on Core-Data rather than just SQLIte. That's why the IDs/URLs are completely different now. I think there is no way to map between the old and new IDs. I would guess that in the future the IDs will be persistent (the way core-data works).
Cheers
Hendrik

Related

PHAsset - Property way to save captured PHAssets locally? (in app)

trying to understand the concept for Photos/Photos.h framework.
my goal is:
write captured video url (or asset) to app's "userDefaults".
read from "userDefaults", & fetch each saved asset data (thumbnail & url)
Since you're not providing any code (nor asking for any), I can help sort some of this out for you -- but you need to study a bit more before you can put it all together. Especially if you think you've asked a question which has one simple correct answer.
UserDefaults is not a good place to store an image. Images are big. (You should look at Apple's documentation of what UserDefaults is for/how it's intended use).
UserDefaults
There's more than one place to store images. Do you want the system to delete them if you start running out of memory? Then it belongs in cache:
let cachesPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).last!
Do you want to depend on it being around the next time the app is run? There is a standard place for that as well:
let userDocumentsFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
Do you want iTunes to back up the images for you automatically? It expects files to be in a certain place for automatic backup. Do you have a way to keep track of where it is (the path to the file can change if the app is re-run). For that you might require persistent storage, so CoreData or Realm might be an option for you. Or you could scan your directory and create a list of files you've already saved. Then you'll need a way to select the correct one. (What did you call it? Should the user select it?)
Apple has very clearly written and useful documentation on access to the Photos library and using PHAssets. Here's just one example:
PHAsset - Photos
There are a lot of talented people on this site, and they are willing to help you, but you need to do your homework before coming here.
I recommend you read these linked documents, start writing some code, and if you run into problems please come back and ask any specific question you have about any specific problem you've encountered. Include the code which causes the problem, as well as the exact error message you are getting. We will be glad to help.

Any reliable way to remember UPnP mediaserver media file location?

I'm working on a mediarenderer client project which needs to memorize last played media file. I initially stores from service and thought that it would be fine until I discovered that the media ObjectID is not permanent.
For example, I have 2 files A.mp3 and B.mp3 with ObjectID "1" and "2" respectively. If I remove A.mp3 and restart the media server, it assign "1" to B.mp3 while I thought it would still be "2". This happens on both mediaservers (pms, minidlna) I tried out.
So my question: What info can I use to remember the media file location other than storing the full hierarchy (eg. /path/to/music.mp3) as I need to resolve the path step by step to obtain the playback URL which I think is less efficient.
I came into a conclusion that UPnP Media Server simply did not define a usecase for this. And I tested out VLC media player and found that they are facing the same issue, hence this issue doesn't deserve a workaround perhaps.

iOS 5 Newsstandkit where does it store downloaded issues?

I'm trying to figure out more about iOS 5 newsstand kit and where it stores the downloaded issues, I have read the documentation and can see that there is an NKLibrary class but cannot see any indication on how to handle the downloads or where they are actually stored.
Thanks
Ok, so NewstandKit works a little differently than you might expect. Take a look at this for the nitty gritty: http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/NewsstandKit_Framework/_index.html
But, Basically during the issue download the app should be passing its (the product's) information including it's NSURL an NKIssue via [NKIssue addAssetWithRequest]. Assuming the download doesn't fail and you have done the other Newstand stuff right, the product should be saved in the properly and you do not have to worry about dictating a specific location for it to be saved.
Another reason to not worry too much about where the issues are being saved, is that Newstand will delete old issues if the device's storage becomes limited.
Hope that helps.
Never worrying about the downloads's destination might not be the best way to deal with the problem. It's true that the destination is chosen automatically when downloading an asset. However, what's saved then is just a temporary file, which must be moved somewhere else and which might also need to be processed in whatever way.
Take a look at the "contentURL" property in NKIssue. This is the location which NewsstandKit recommends as the very destination of issue-related assets.
Cheers :)

Graph API not returning image/picture for community pages

Graph API is not returning image("picture" attribute) for objects corresponding to community pages, which used to be returned earlier. For example this https://graph.facebook.com/178790412179919 does not have picture attribute whereas the corresponding page has an image.
Also the FQL query done on the "albums" connection for some objects does not have a "cover_pid" attribute for an album corresponding to type "profile", which again used to work earlier.
Does anybody know if anything has changed in Graph API corresponding to this in last couple of weeks (I am fairly confident it used to work earlier in the expected way). I looked through Facebook API release notes but could not find any changes corresponding to this. Please let me know if this not appropriate post for this forum.
https://developers.facebook.com/docs/reference/api/page/
picture is a connection, not an attribute. So ...
https://graph.facebook.com/178790412179919/picture
And as the docs say: Returns a HTTP 302 with the URL of the user's profile picture.
Kinda goofy? Yes, but it works exactly as the docs say it does. I suspect they implemented it this way so it could easily be used in an <IMG> tag.
UPDATE:
It still works via FQL. In your case:
https://api.facebook.com/method/fql.query?query=SELECT+page_id%2C+pic+FROM+page+WHERE+page_id+%3D+178790412179919&format=json
I can confirm that this PREVIOUSLY worked, but NO LONGER works. Facebook have removed the picture connection from Community Pages.
I suspect the reason is that most of these images are pulled from Wikipedia, and there was a licensing / attribution issue.
Unfortunately, Facebook is no longer a reliable source of images for entities (e.g. bands).

Cache a JSON string from a URL Request

I have about 3 different requests which are made to a url which retrieve an extensive JSON string. I would like to store this in the cache in the event that the iPhone does not have an internet connection at next launch.
What is the best method for this? I am fairly new to Objective-C and xCode. I have researched NSURLCache and NSCache, but not sure which I should use.
I would also like to know if there is a way to preload this JSON string in the background. Or at least show a preloader view. Two separate questions, I know.
Thanks for pointing me in the right direction.