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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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-21-2009, 10:30 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 24
Smile Sticky/slower searching

Code:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
	
	// remove all data that belongs to the previous search
	[TtableData removeAllObjects];
	[RtableData removeAllObjects];
	[BtableData removeAllObjects];
	
	if([searchText isEqualToString:@""] || searchText==nil) {
		[myTable reloadData];
		return;
	}
	
	NSString *searchLower = [searchText lowercaseString];
	
	NSInteger counter = 0;
	
	for(NSString *name in BdataSource) {
		NSString *nameLower = [name lowercaseString];
		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
		NSRange r = [nameLower rangeOfString:searchLower];
		
		if(r.location != NSNotFound) {
			[RtableData addObject:[RdataSource objectAtIndex:counter]];
			[TtableData addObject:[TdataSource objectAtIndex:counter]];
			[BtableData addObject:[BdataSource objectAtIndex:counter]];
		}
		
		counter++;
		[pool release];
	}
	
	[myTable reloadData];
}
This is the search method employed by my program. I used to have my program set up so that you had three windows. Navigation, search, and detail. Normally, you would make a selection in navigation and it would go straight to detail, but if you wanted to search, you would make a pit stop, and then load detail. With this structure, the search functioned smoothly on my test device.

When I merged search into navigation, and used a BOOL to have the navigation functions switch between normal and searching, the search still worked, but it had slowed down a lot. I keep getting 'sticky buttons' while I'm typing into the search bar.

It's the same code, but . . .
All the arrays were allocated, and initiated in ViewDidLoad. The DataSources were also populated there.
Does anybody know how I can streamline this search, and make it run smoothly again?
mazraf is offline   Reply With Quote
Reply

Bookmarks

Tags
lag, navigation, search, slow, sticky

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: 259
20 members and 239 guests
2WeeksToGo, ADY, BrianSlick, dacapo, Dani77, Dattee, Duncan C, headkaze, IphoneSdk, jemicha, kapps11, mer10, mgon987, Punkjumper, sneaky, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,743
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

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