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 01-26-2012, 04:28 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 43
iAppCode is on a distinguished road
Default Want to search a tableview and compare the results

Hi everyone,
I am sitting on this problem for quite a long time and just don't know the answer. I have got a tableview where you can find all the titles of your music library and in the detailtextlabel there you can find the artist of the song. So this is easy, but I want to search now for an artist and the tableview of the search bar should show me all the songs from the given artist. I want to do this with the following code:
Code:
        int u=0;
       
        for (NSString *newsong in  arraywithartists)
        {
                  untertitel = [[self searchResults] objectAtIndex:row];
            
             if ([newsong rangeOfString:untertitel options:NSCaseInsensitiveSearch].location != NSNotFound)
            {
                
                
                contentForThisRow = [arraywithsongtitles objectAtIndex:u]; 
                
                
            }
            u++;
        }
  
        
   
   
    }
    else{
        contentForThisRow = [arraywithsongtitles objectAtIndex:row];
       untertitel = [NSString stringWithFormat:@"%@ - %@",[arraywithartists objectAtIndex:row],[arraywithalbumtitles objectAtIndex:row]];
      
    }
Unfortunately it does not work. The search table view shows me the number of the songs of the artist, but in contentforthisrow there is only one song of this artist which is shown in all cells. arraywithartists,arraywithsongtitles,arraywithalbu m are of cause the arrays with all my artists, songs and albums.
I don't know what to do. It just won't work. Thank you so much for any help!
Many greetings,
Tim
iAppCode is offline   Reply With Quote
Old 01-26-2012, 04:43 PM   #2 (permalink)
Registered Member
 
ebender001's Avatar
 
Join Date: Mar 2010
Location: Missouri
Age: 57
Posts: 70
ebender001 is on a distinguished road
Default

Quote:
Originally Posted by iAppCode View Post
Hi everyone,
I am sitting on this problem for quite a long time and just don't know the answer. I have got a tableview where you can find all the titles of your music library and in the detailtextlabel there you can find the artist of the song. So this is easy, but I want to search now for an artist and the tableview of the search bar should show me all the songs from the given artist. I want to do this with the following code:
Code:
        int u=0;
       
        for (NSString *newsong in  arraywithartists)
        {
                  untertitel = [[self searchResults] objectAtIndex:row];
            
             if ([newsong rangeOfString:untertitel options:NSCaseInsensitiveSearch].location != NSNotFound)
            {
                
                
                contentForThisRow = [arraywithsongtitles objectAtIndex:u]; 
                
                
            }
            u++;
        }
  
        
   
   
    }
    else{
        contentForThisRow = [arraywithsongtitles objectAtIndex:row];
       untertitel = [NSString stringWithFormat:@"%@ - %@",[arraywithartists objectAtIndex:row],[arraywithalbumtitles objectAtIndex:row]];
      
    }
Unfortunately it does not work. The search table view shows me the number of the songs of the artist, but in contentforthisrow there is only one song of this artist which is shown in all cells. arraywithartists,arraywithsongtitles,arraywithalbu m are of cause the arrays with all my artists, songs and albums.
I don't know what to do. It just won't work. Thank you so much for any help!
Many greetings,
Tim
Every time I code a search, I have to look everything up in the docs. However, the usual routine is to create a mutable array and fill that array with what is filtered from your original table datasource. It seems in your case it should be an array of NSDictionaries with keys pointing to your songs and artists.
Use the UISearchBarDelegate methods (searchBar:textDidChange to filter through your original datasource. Make the new mutable array the datasource of the table and reload the tableview.
This should get you on your way.

Ed
ebender001 is offline   Reply With Quote
Old 01-26-2012, 04:52 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 43
iAppCode is on a distinguished road
Default

Thanks a lot! I will try it
iAppCode is offline   Reply With Quote
Reply

Bookmarks

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: 402
9 members and 393 guests
Atatator, condor304, FrankWeller, MAMN84, mraalex, n00b, PowerGoofy, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,123
Posts: 402,908
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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