forum

Home / DeveloperSection / Forums / Finding a NSString in an Array in a Master Array

Finding a NSString in an Array in a Master Array

Anonymous User179915-Jul-2015

I have a string called alpha.

alpha= @"pie"

I have 3 arrays that were added into a master array called "ALL WORDS"

array 1 = [nsarray alloc]initwithobjects @"cake", @"donut"];

array 2 = [nsarray alloc]initwithobjects @"cream", @"pie"];

array 3 = [nsarray alloc]initwithobjects @"rice", @"flour"];

 

 

    allwords = [NSMutableArray array];

    [allwords addObjectsFromArray:array1];

    [allwords addObjectsFromArray:array2];

    [allwords addObjectsFromArray:array3];

So now I am doing a for loop like this

 for (int i = 0; i < [allWords count]; i++)

 {

        NSString *takestring =[allWords objectAtIndex:i];

        if ( [takestring is equal to alpha]) {

           //tell which array alpha or takestring came from????           

        }       

 }

My question is, how can I determine which array the pie came from. in the app people might have new words that I might not know, but i want to be able to detect where that string what array is it from?

Anybody knows how I can do this??


Updated on 15-Jul-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By