iPhone: To store photo album image URL's and compare later: - iphone

As per my query from the below link, i've implemented retrieving photo album images from ALAsset Library.
Upload ALAsset URL images to the server
I get the images Asset URL's like below,
"assets-library://asset/asset.JPG?id=1000000001&ext=JPG"
"assets-library://asset/asset.JPG?id=1000000002&ext=JPG"
"assets-library://asset/asset.JPG?id=1000000003&ext=JPG"
I want to store these in a database (or) file [I don't know which is suitable for comparison for later purposes]. Next time(say,after 30 mins), i want to get again all the image URL's from Asset and compare with the previous image URL's which has stored in a DB, to find if any new images has been added in photo album or not. If any new image is been added in photo album, then i get that image in my code.
I want to know, what should i use to store the image URL strings, whether SQLite database (or) file, and next time which one should be sufficient to compare the previous data and the current data? I thought of going with creating sqlite database and store the data and compare the image URL strings with the stored data like that …. Am i thinking right to go? If yes, may i know how to store the data(image URL strings) in a sqlite database and do comparison between new image URL's and stored data?
I created a sqlite database through Firefox sqlite manager plugin and added a table. I'm not getting any samples further to go through to solve my purposes, i.e. store the image URL strings in sqlite database and do comparison between the stored image URL strings and new image URL strings which i got from Asset library.
Please help and advise.
Thank you!

yes you are going right. Use sqlite database to store URLs follow the tutorial
http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/

Edit..sorry, i missed the last comment that explains what you want to do..
Here
http://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/iPhoneCoreData01/Introduction/Introduction.html
do that tutorial to learn how to set up the database and core data, you'll see how they save information - and from there just change code to suit your needs
Edit again.. after that you can use predicates to pull out info you need, and/or use string comparisons (Google "iPhone sdk compare strings") to compare to a new string.
or create an array of existing URL's and do something like
if ([myArrayOfURLS containsObject:theNewUrl]) {
[self doSomethingWithMyNewURLIGuess];
}

Related

Saving screenshot to CoreData

I'm developing an app that I want the user to be able to take a screenshot with a button (this works, but it's stored to camera roll). I have a need to keep history of these screenshots along with site name, etc.
I've been reading that it's not recommended to save binary data in a sqlite db, so I've stumbled across core data. I'm still learning, but one question that comes to mind is this. Some recommend to save the filename to coredata and then save the image to document directory. I want to read the data back into a table view controller and have the image part of the cell. Will I need to resize the image to the size I want when reading in, or will it automatically size down to what it needs?
Also, when saving to document directory, are those files accessible from the camera roll? I don't want them to be and I'd like to give the user the ability to be able to delete them with the tableviewcontroller.
Please let me know if I need to expand on anything. I'm learning Swift, so I'm sure I missed something.
You should not save it to the Documents directory.
You should instead Allow External Storage of the attribute. Core Data will take care of storing it for you. This is explained in the answer by jansenmaarten to this question.

Store Image path in database

I am making a app in which I am retrieving data from Database in List View.
I want to have different picture with each data I retrieve from database in list View.
What I am trying to do is to save my pictures in drawable folder of my app and want to save image path in database and retrieve my image from saved path.
I searched lot on internet but couldn't get appropriate solution.
Somebody please show me appropriate code.
Don't know if you already have solved this problem,
but after looking for it myself i found a solution.
what i did was use this.
i stored my images in a subfolder in "Assets" and this works like a charm,
don't know how many images it can hold in total, but i'll find out eventually i guess xD

Best way to load a lot of images from a server in iphone

I'm developing an app and one of its features is similar to twitter,so I have a table with each "tweet" and I display the user's picture too and I don't know what is the best way to load a lot of pictures. The images come from the server as an url.
My app's structure is:
1- I call to the server, and I get the response
2- I parse the response and I iterate it creating objects
3- I load that objects in the tableview's store
4- I reload the table
I thought one way is when I am creating the object, I load the image and I assign to the object's attribute. I mean, each time I create a object type "tweet" for example, I create the image calling the url with nsdata...
I dont know if that solution is correct or can be better. Can anyone give me a hand? Thanks in advance
Take a look at the SDWebImage API. It will do much of this automatically for you.

Is URL obtained from UIImagePickerControllerReferenceURL stable?

I get the Asset Library URL for a photo using the UIImagePickerControllerReferenceURL key on the info dictionary obtained from UIImagePickerController. The url looks like this:
assets-library://asset/asset.JPG?id=1000000002&ext=JPG
Is this URL stable? Can I expect to save it in a document and then at a later date fetch the photo using this URL?
I basically have a iOS photo editing app where I allow the user to do some editing on a bunch of photos. I allow the user to save the project and edit at a later date. I would save these URLs to save the information about which photos are used in the project. I don't want to copy and save all the photos used in a project since there can be many photos used in a project and this will result in unnecessary duplication.
Can you also suggest if there is a better way around.
Asset URLs are supposed to be stable but the format changed between iOS3 and iOS4 and the format in iOS5 is something like '/asset/FA8F1400-82A5-424F-A98C-2883754FA54D.jpg'. You shouldn't store asset URLs and expect them to remain valid forever, which is a shame because that is exactly what you would expect.
You could protect yourself by storing the asset's date and maybe location if it is set. Then if your app needs to, it can go through the asset library and patch up the references if the URL format changes again.

Storing data into an XML under iOS

I'm using an NSXMLParser to read data out of a XML, but how can I make my iPhone App storing data into this specific XML.
The case is that I want to create an app to display available dates and one that administrates this dates, whether they are available or not (I'm using an UISwitch to handle this).
Thanks for your answers,
btype.
If you have small amount of data, you can save them in a plist.
See Property List Programming Guide
There's a github project that let's you create XML DOM objects. You can save your XML to your documents folder on the phone.
https://github.com/arashpayan/apxml/