iOS Developer

  Home  Smartphone OS  iOS Developer


“iOS Developer based Frequently Asked Questions in various iOS Developer job interviews by interviewer. These professional questions are here to ensures that you offer a perfect answers posed to you. So get preparation for your new job hunting”



102 IOS Developer Questions And Answers

41⟩ How to deal with SQLite database?

Dealing with sqlite database in iOS:

☛ 1. Create database : sqlite3 AnimalDatabase.sql

☛ 2.Create table and insert data in to table :

CREATE TABLE animals ( id INTEGER PRIMARY KEY, name VARCHAR(50), description TEXT, image VARCHAR(255) );

INSERT INTO animals (name, description, image) VALUES ('Elephant', 'The elephant is a very large animal that lives in Africa and Asia', 'http://dblog.com.au/wp-content/elephant.jpg');

☛ 3. Create new app --> Add SQLite framework and database file to project

☛ 4. Read the database and close it once work done with database :

// Setup the database object

sqlite3 *database;

// Init the animals Array

animals = [[NSMutableArray alloc] init];

// Open the database from the users filessytem

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {

// Setup the SQL Statement and compile it for faster access

const char *sqlStatement = "select * from animals";

sqlite3_stmt *compiledStatement;

if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {

// Loop through the results and add them to the feeds array

while(sqlite3_step(compiledStatement) == SQLITE_ROW) {

// Read the data from the result row

NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];

NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];

NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];

// Create a new animal object with the data from the database

Animal *animal = [[Animal alloc] initWithName:aName description:aDescription url:aImageUrl];

// Add the animal object to the animals Array

[animals addObject:animal];

[animal release];

}

}

// Release the compiled statement from memory

sqlite3_finalize(compiledStatement);

}

sqlite3_close(database);

 137 views

56⟩ Explain usage of struct?

struct is a Datatype in C Programming Language that enables encapsulation of other pieces of data into a single cohesive unit. It is similar to an object but in C Programming Language.

 128 views

57⟩ What is a Collection?

A Collection is a Foundation Framework Class that is used to Manage and Store the group of Objects. The primary role of a Collection is to store Objects in the form of either a Set, a Dictionary or an Array.

 133 views