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)

AppFusion - 6 in 1!
($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 01-27-2012, 05:09 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 33
Default Dealing with a special loop

Hi,
I need just a little hint from you. Here is my code:
Code:
 contentForThisRow = [[self searchResults] objectAtIndex:row];
     for (NSString*strinoftitle1 in arraywithartists){
            
            
            if ([strinoftitle1 isEqualToString:contentForThisRow]){
                contentForThisRow=[arraywithsongtitles objectAtIndex:t];
                
            }
            t++;
        }
It is not so difficult as it sounds (-; I get a search result from a search tableview and look if it is equal to a string in a mutable array. If this is the case, another string of a mutable array which belongs to this string should be shown in a cell. Unfortunately there are more than one in "arraywithartists". So when I look up for for example "Stevie Wonder" this string is found very often(because Stevie Wonder has got more than one song), but there is only the first song from him shown [arraywithsongtitles objectatindex:t].
I believe that I have to say my for loop that it should go on with the next stringoftitle1 after objectatindex:t was opened.
Maybe some of you know how to do that? This would be so nice because it is the last thing I have to do. Thank you very much!
Greetings,
Tim

Last edited by iAppCode; 01-27-2012 at 05:21 PM.
iAppCode is offline   Reply With Quote
Old 01-27-2012, 05:41 PM   #2 (permalink)
[[Brain alloc]init];
 
fhsjaagshs's Avatar
 
Join Date: Aug 2011
Location: New Jersey
Age: 15
Posts: 75
Default

Quote:
Originally Posted by iAppCode View Post
Hi,
I need just a little hint from you. Here is my code:
Code:
 contentForThisRow = [[self searchResults] objectAtIndex:row];
     for (NSString*strinoftitle1 in arraywithartists){
            
            
            if ([strinoftitle1 isEqualToString:contentForThisRow]){
                contentForThisRow=[arraywithsongtitles objectAtIndex:t];
                
            }
            t++;
        }
It is not so difficult as it sounds (-; I get a search result from a search tableview and look if it is equal to a string in a mutable array. If this is the case, another string of a mutable array which belongs to this string should be shown in a cell. Unfortunately there are more than one in "arraywithartists". So when I look up for for example "Stevie Wonder" this string is found very often(because Stevie Wonder has got more than one song), but there is only the first song from him shown [arraywithsongtitles objectatindex:t].
I believe that I have to say my for loop that it should go on with the next stringoftitle1 after objectatindex:t was opened.
Maybe some of you know how to do that? This would be so nice because it is the last thing I have to do. Thank you very much!
Greetings,
Tim
I need more information (preferably in a less verbose manner, remember programmers = lazy)
fhsjaagshs is offline   Reply With Quote
Old 01-27-2012, 05:57 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 33
Default

OK Thank you for your help!
I know this is a bit confusing, but the idea is very simple. I have got two arrays: arraywithsongtitle and arraywithartists. They are filled with the informations in my music library. So in arraywithsongtitle there are all the songs as strings and in arraywithsongtitle there are the artists which belongs to these songs. Now both informations are in a normal tableview. It is very similar to your iPod app. Now I want to search this tableview. And I don't just want to search for a title - this is easy. I want to search for both artists and titles. Therefore I wrote this loop. When I type something in my search bar it looks throw all the artists - for (NSString*strinoftitle1 in arraywithartists).
When it finds an artist (as a string) which is equal to what I typed in my search bar, it should remember the location of that artist in the array. So this is nice because I know now which titles there are to present, you understand? I just say that it should write the song titles of the artist into the cells. (contentforthisrow=[arraywithsongtitles objectAtIndex:t]) and I am adding 1 to t every time the loop ran throw. It sounds logically for me and I think it should work, but unfortunately the tableview just presents the first title in arraywithtitles of a special artist.
I know that it is a bit confuse, but thank you for any kind of an answer. I don't know who to ask (-;

Last edited by iAppCode; 01-27-2012 at 05:59 PM.
iAppCode is offline   Reply With Quote
Old 01-27-2012, 06:41 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2010
Location: Seattle, WA
Posts: 253
Default

not sure exactly what u are doing, but what you probably want is a 3rd mutable array. And 2 seperate for loops, one for artist and one for song title. whenever you find a song or artist matching your search, put the contents onto the third array. After finishing both loops, your 3rd array will be complete. Use that one to populate your cells.
__________________
Check out my apps

RickSDK 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: 647
24 members and 623 guests
ADY, BrianSlick, cotzy, Creativ, dacapo, Dattee, e2applets, gbenna, IphoneSdk, iseff, jakerocheleau, Jamarsoft, jbro, JiDai, kampftrinker, linkmx, mashercakes, nimesh_158, Reyna, touchcream, ukneeq, yurikus
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 160,619
Threads: 89,833
Posts: 383,488
Top Poster: BrianSlick (7,243)
Welcome to our newest member, yurikus
Powered by vBadvanced CMPS v3.1.0

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