NSMutableArray*array = [[NSMutableArray alloc]init];
NSArray*Somearray = [NSArray arrayWithObjects:1st Object,2ndObject,3rd Object,4th object,5th Object,nil];
В указанном выше массиве 1-й объект, 2-й объект, 3-й объект, 4-й объект, 5-й объект, имеющий val, content, вывод в каждом индексе.
for(int i=0;i<[Somearray count];i++)
{
______________
Here the code is there to give each index ,that is having val,content,conclusion ..
After that val,content,conclusion in each index will be add to Dict..
____________
NSDictionary *Dict = [NSDictionary dictionaryWithObjectsAndKeys:val,@"val",content,@"content",conclusion,@"conclusion",nil];
//Each time adding dictionary into array;
[array addObject:Dict];
}
Указанный выше словарь находится в цикле for ипары значений ключа будут добавлены 5 раз (Somearray Count). Теперь массив имеет значение
array = [{val="1.1 this is first one",content="This is the content of 0th index",conclusion="this is the conclusion of 0th index"},{val="1.2 this is first one",content="This is the content of 1st index",conclusion="this is the conclusion of 1st index"},____,____,______,{val="1.5 this is first one",content="This is the content of 4th index",conclusion="this is the conclusion of 4th index"},nil];
Теперь у меня NSString*string = @"1.5";
Теперь мне нужен индекс, в котором значение val равно 1,5в нем. Как отправить str в массив, чтобы найти индекс.
Может кто-нибудь поделиться кодом, пожалуйста.
Заранее спасибо.