Non sono sicuro se quello che sto per chiedere è in realtà un NSDictionary
con più chiavi, ma ok.Come creare un NSDictionary con più chiavi?
Quello che voglio fare è creare un NSDictionary
con chiavi e valori per i miei dati e quindi convertirlo nel formato JSON
. Il formato JSON
apparirebbe esattamente come questo:
{
"eventData": {
"eventDate": "Jun 13, 2012 12:00:00 AM",
"eventLocation": {
"latitude": 43.93838383,
"longitude": -3.46
},
"text": "hjhj",
"imageData": "raw data",
"imageFormat": "JPEG",
"expirationTime": 1339538400000
},
"type": "ELDIARIOMONTANES",
"title": "accIDENTE"
}
io ho usato solo NSDictionaries
come questo:
NSArray *keys = [NSArray arrayWithObjects:@"eventDate", @"eventLocation", @"latitude" nil];
NSArray *objects = [NSArray arrayWithObjects:@"object1", @"object2", @"object3", nil];
dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
Ma il formato di cui sopra non è tutto su chiave - valore. Quindi la mia domanda è: come dovrebbe essere il NSDictionary
, per adattarsi al formato JSON
?? Grazie per aver letto il mio post, e scusa se c'è qualche confusione.
Hai perso una virgola tra @ "latitudine" e zero. – DarkMoon