ios - Adding multiple objects to NSMutableArray -
i have following iteration:
historialservicios = [[nsmutabledictionary alloc]init]; // parse , loop through json (dictionary in messagearray) { //datos de nivel objects nsstring * code = [dictionary objectforkey:@"code"]; nsstring * date = [dictionary objectforkey:@"date"]; //datos de nivel client nsdictionary *level2dict = [dictionary objectforkey:@"client"]; id someobject = [level2dict objectforkey:@"email"]; nslog(@"nombre===%@",someobject); nsstring * email = someobject; nslog(@"email=%@",email); nslog(@"code=%@",code); nslog(@"date=%@",date); //insertamos objetos en diccionario historialservicios }
the iteration looping inside root node of json tree , inside child node "client".
what need create nsmutablearray of dictionaries. each dictionary has include retrieved objects each iteration, in case keys code, data , email. code , data root node, , email child node.
following example, each dictionary should object keys , values:
keys values code nsstring code date nsstring date email nsstring email
how can perform way create nsmutablearray?
try:
historialservicios = [[nsmutabledictionary alloc]init]; array = [nsmutablearray new]; // parse , loop through json (dictionary in messagearray) { //datos de nivel objects nsstring * code = [dictionary objectforkey:@"code"]; nsstring * date = [dictionary objectforkey:@"date"]; //datos de nivel client nsdictionary *level2dict = [dictionary objectforkey:@"client"]; id someobject = [level2dict objectforkey:@"email"]; // adding array [array addobject:@{@"code": code, @"date": date, @"email":someobject}]; nslog(@"nombre===%@",someobject); nsstring * email = someobject; nslog(@"email=%@",email); nslog(@"code=%@",code); nslog(@"date=%@",date); //insertamos objetos en diccionario historialservicios }
Comments
Post a Comment