2017-04-07 1 views
-1

mein Array, wie man Array umwandeln, die ein Wörterbuch Objective-c

{ 
    cash = 860; 
    flat = 157; 
    propertyName = "Four seasons"; 
}, 
    { 
    cash = 540; 
    flat = 156; 
    propertyName = "Four seasons"; 
}, 
    { 
    cash = 560; 
    flat = 155; 
    propertyName = "Four seasons"; 
} 

wie Array konvertieren, die mit dem Wörterbuch ein Wörterbuch mit den gleichen Strings in einem anderen Array ist

{ 
    cash1 = 860; 
    cash2 = 540; 
    cash3 = 560; 
    flat1 = 157; 
    flat2 = 156; 
    flat3 = 155; 
    propertyName = "Four seasons"; 
}, ... 
+0

Was haben Sie versucht? – Willeke

+0

Alle Wörterbücher im Array haben die gleichen Schlüssel? – Larme

+0

ja haben 4 Schlüssel –

Antwort

-1

Dies könnte dir helfen.

FYI ist dies viel einfacher ...

NSMutableDictionary *result = [[NSMutableDictionary alloc]init]; 
    for (NSDictionary *dict in yourArray) 
{ 
    [result addEntriesFromDictionary:dict]; 
} 
+0

Wenn alle Wörterbücher den gleichen Schlüssel haben, haben Sie nur das letzte Wörterbuch. Weil es Unicity gibt, wenn der Schlüssel in einem Wörterbuch ist. – Larme

Verwandte Themen