2017-11-07 15 views
0

私は2NSArray全体で異なるJSON objectForKeyを削除するにはどうすればよいですか?

if(requestType == RequestTypeGetReportMaterialStatus) 
      { 
       materialStatusArray=response[@"customerstatus"]; 
       NSLog(@"Filtered Array2%@",materialStatusArray); 
} 

1 =  { 
    bookingid = 469; 
    status = 1; 
}; 
2 =  { 
    bookingid = 493; 
    status = 1; 
}; 
3 =  { 
    bookingid = 486; 
    status = 1; 
}; 
4 =  { 
    bookingid = 501; 
    status = 1; 
}; 
5 =  { 
    bookingid = 506; 
    status = 1; 
}; 

フィルタ配列の応答を以下している。しかし、私は数字

{ 

    bookingid = 469; 

    status = 1; 

}; 

    { 

    bookingid = 493; 

    status = 1; 

}; 

    { 

    bookingid = 486; 

    status = 1; 

}; 

    { 

    bookingid = 501; 

    status = 1; 

}; 

    { 

    bookingid = 506; 

    status = 1; 

}; 

どのように取得することができますを切断して入れて、次を与える配列に格納さへの応答にしたいです配列の応答の上記のフォーマットは、比較目的のために予約IDと状態値にアクセスします...私の応答に従ってコードスニペットを与えることによって私を助けてください。

ありがとうございました。

答えて

0

私はmaterialStatusArrayが実際にNSDictionaryのだと思いますが、配列は次のように変換することができます

NSMutableArray *arrayWithoutNumbers = [NSMutableArray array]; 

if ([materialStatusArray isKindOfClass:[NSDictionary class]]) { 
    NSDictionary *dict = (NSDictionary *)materialStatusArray; 
    [dict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { 
     [arrayWithoutNumbers addObject:obj]; 
    }] 
} 
+0

この完璧なソリューションであり、感謝! – Fido

関連する問題