Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-25-2009, 06:32 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 109
raheel is on a distinguished road
Default Best practises, Fine tunning my SQL App,

Hi guys,
Im really glad to say that my application framework and design is coming an end and the SQL data entries are beginning!..
I have some questions regarding best practises and application performance.

1] My application takes some time after getting tapped to show up.. I think theres a second of black view and then the tabbar app appears. The testing is being done in iPod device
I dont really call much in AppDidfinishLaunching except
Code:
	

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
	[window addSubview:tabBarController.view];
//All arrays are synthesized.. and dealloc-ed
	SList = [[NSMutableArray alloc] init];
	sMap = [[NSMutableArray alloc] init];
	SMList = [[NSMutableArray alloc] init];
	ConditionsList = [[NSMutableArray alloc] init];
c1=[[NSArray alloc] initWithObjects:@"item0", @"item1", @"item2",nil];
//2 more similar NSArrays but with more NString data.
	[window addSubview:tabBarController.view];
	[self initialiseDatabaseCondition:@"SELECT ID FROM sList"];

-(void)initialiseDatabaseCondition:(NSString *)sqline{
	[ConditionsList removeAllObjects]; //This initialisation is executed multiple times.. so I clear the List everytime its called.

	NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"DB.sqlite"];
	if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
		const char *sqln = [sqline UTF8String];
        sqlite3_stmt *statement;
		if (sqlite3_prepare_v2(database, sqln, -1, &statement, NULL) == SQLITE_OK) {			
            while (sqlite3_step(statement) == SQLITE_ROW) {
                int pk = sqlite3_column_int(statement, 0);	
				ConditionClass *nCon = [[ConditionClass alloc] initWithPrimaryKey:pk database:database];
				[ConditionsList addObject:nCon];
				[nCon release];
			}
		}
		sqlite3_finalize(statement);
	}else{
		sqlite3_close(database);
        NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
		//[self say:@"failed"];
	}
}
The initialiseDatabaseCondition grabs stuff from the SQLite db in a very exactly the same way as the example - SQLiteBooks. Any comments here.. to speeed up the process of loading would be great.

I've seen some apps like (SQLiteBooks) that start with animation.. kinda,, like on tapping, the view appears with animation. In my case, the black view animates and shows up and then the tabbar view is added to it. How can i rectify/change this design flaw!??
They've got a default.png...

2]All arrays are in the AppDelegate. And I'm using them from all other controllers. Almost every controller's methods have this linkage. All tableView methods, pickerViews.. etc..
Code:
	SDAppDelegate *appDel = (SDAppDelegate *)[[UIApplication sharedApplication]delegate];
Should I localise the arrays to specific controllers if applicable/possible?

3] I have a method, where I initialise the Database everytime depending on what the user chooses.. Like initialiseDatabaseWith@"Select ID from table WHERE site=";
I kinda use NSString stringwithFormat method to attach the site=? to the string and call initialiseDatabase.. Since I'm calling it evertime the user chooses, As earliar you've seen in the code, I clearedAllObjects from that specific NSMutableArray.
There isnt much memory handling here, since i know little about it..
Is there a better way to save up memory and reload an array.. etc??

4]SQL caching..? i dont know anything about it.. and direction is appreciated.

5]I have about 4 tableviews, One requires checkmarks like -TouchCells, the other requires a subtext below the main text, another needs a disclosure indicator, etc..
Due to my incredible laziness, i added booleans to my CustomCell and made a single Class to handle all 4 tableViews.

Code:
	static NSString *kCustomCellID = @"MyCellID";
	CustomCell *cell = (CustomCell *)[self.tableView dequeueReusableCellWithIdentifier:kCustomCellID];
	if (cell == nil)
	{
		cell = (CustomCell *)[[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCustomCellID] autorelease];
	}
	cell.moreIndicatorNeeded = YES; //its the disclosureIndicator
	cell.subtxtNeeded = YES;
	SDAppDelegate *appDelegate = (SDAppDelegate *)[[UIApplication sharedApplication] delegate];
	ConditionClass *nCon = (ConditionClass *)[appDelegate.ConditionsList objectAtIndex:indexPath.row];
	cell.title = nCon.txtCondition;
	cell.subtxt = [appDelegate.pp objectAtIndex:nCon.System];
	return cell;
This is an example of one! tableView... the other may say NO to those booleans

6]Sometimes I feel im depending too much on my AppDelegate.. is it any real concern? But There had to be a common link between them!.. atleast for 2 mutablearrays that check and compare each other..

and, if u still have some time for me ,

HOW TOs: In my pickerView, i changed the Views. made its inside look great. with different fonts and different background colors..
But theres one problem, The PickerView Color inside remains white. its only "pickerItems" change the background view to orange..or something
THis is apparent on scroll.. when the data finishes, the white color appears.. So i concluded that since im slapping my view over it as pickerItems, thats happening,
How can I change the Background white color of the pickerview entirely!.. IVE SEEN some apps that way
raheel is offline   Reply With Quote
Reply

Bookmarks

Tags
sql

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 325
13 members and 312 guests
chiataytuday, coolman, givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mottdog, mtl_tech_guy, Punkjumper, vilisei, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0