I have an array of entity class (eg SubmittedAnswer). Its JSON format is look like as below.
{
\"submittedAnswers\": [{
\"submittedQuestionId\": \"C7B3
Assuming that submittedAnswers
is an NSArray of NSDictionary objects, I found the answer here:
Stack Overflow > iPhone - Searching NSArray of NSDictionary objects
// Array `submittedAnswers` of sample data
NSArray* submittedAnswers = @[
@{
@"submittedQuestionId" : @"C7B3C4BE-CC3C-438F-A118-E798884A5FE0" ,
@"serialNumber" : @4 ,
@"option" : @" it has a very large mass." ,
@"testQuestionId" : @"55230160-b905-47d5-a91c-e1dda6dd0634" } ,
@{
@"submittedQuestionId" : @"9A6E9EA8-1BC0-4ED9-81E8-28B7E554D5E0" ,
@"serialNumber" : @1 ,
@"option" : @" downward" ,
@"testQuestionId" : @"fd0b3ae0-e999-48a6-89b8-a89b02e7b793" } ] ;
NSString *submittedQuestionId = @"9A6E9EA8-1BC0-4ED9-81E8-28B7E554D5E0" ;
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"submittedQuestionId = %@", submittedQuestionId] ;
NSArray* foundQuestions = [submittedAnswers filteredArrayUsingPredicate:predicate] ;
NSDictionary* foundQuestion = foundQuestions[0] ;