iPhone: Source code demo

iPhone code snippets


To go through this tutorial, a programming knowledge in Objective C and Hypertext Transfer Protocol (HTTP) is preferred.

Download complete demo source code for iPhone

Technical requirements:

Mac OS X version 10.5 Leopard or later
Xcode 3.1
iPhone 3.1 SDK


IDrive EVS Photo Backup for iPhone

Photo Backup is an iPhone-based application, which allows the user to:
This is how it works:
To begin with, download and unzip the source code. Now, open the source using Xcode by double-clicking on PhotoBackup.xcodeproj file found in the project source folder.

The sample Photo Backup application, puts up login screen, with username and password fields as shown below:

(Sign up with IDrive and provide user credentials in Photo Backup application.)

login

Enter the registered username and password and click the Login button.
NSURLRequest object for login request is created and executed in WebService class.

Below is the code snippet for WebService class:
After the successful validation, enter the private encryption key as shown below:

Encryption key

On successful confirmation, a screen will be displayed with Backup, File / folder listing and Search options as shown below:

Successful confirmation

Backup photos from Photo library to IDrive account
Select the image that you wish to backup from the image list. The application transfers the selected image file to your IDrive account. The below screen displays backup operation in progress.

Backup

Once the image is selected form the imagePicker, the image file is created under
"Documents/PhotoBackup/Photos folder" path. This path will be used by the WebService object for creating the backup request object.

Below is the code snippet of WebService class, which makes image Backup request:

Files / Folders Listing
Traverse through the file hierarchy by selecting folder in the file / folder list. You can either “Download” or “Delete” the files that are listed.

File listing

File / folder listing response will be in XML format, IDLParser class parse and saves the data in IDLFileAttribute class. Which is later read by IDLTableViewController class (tableview datasource). IDLFileListViewController class handles folder navigation and the file information screen related modules. IDLFileAttribute is a modal class which handles IDLFileInfo and IDLFolderInfo object creation depending upon parsed data.

Below is the code snippet of WebService class, which makes file / folder listing request:

Download photos to Photo library from IDrive account
To perform Restore operation, click the Restore button as shown below:

File information - Restore

IDLFileListViewController class handles the Restore and Delete operations. NSURLRequest object for image restore and file Deletion from IDrive account is created and executed in WebService class.

Below is the code snippet of WebService class, which makes image Restore request:

Delete the file(s) in IDrive account
To perform the Delete operation, click the Delete button as shown below:

File information - Delete

Below is the code snippet of WebService class, which makes file Deletion request:

Search for the file(s) in IDrive account
To perform the search operation, enter the search phrase as shown below:

Search

Based on the search phrase the search results will be displayed as below:

Search results

Search operation response will be in XML format, IDLParser class parse and saves the data in IDLFileAttribute class, which is later read by IDLTableViewController class (tableview datasource).

Below is the code snippet of WebService class, which makes search request: