Wie erstelle ich ein NSDictionary mit mehreren Schlüsseln?
Ich bin mir nicht sicher, ob das, was ich fragen werde, tatsächlich eine istNSDictionary
mit mehreren tasten aber ok
Was ich tun möchte, ist eineNSDictionary
mit Schlüsseln und Werten für meine Daten und konvertieren Sie es dann inJSON
Format. DasJSON
Das Format würde genau so aussehen:
{
"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"
}
Ich habe nur benutztNSDictionaries
so was :
NSArray *keys = [NSArray arrayWithObjects:@"eventDate", @"eventLocation", @"latitude" nil];
NSArray *objects = [NSArray arrayWithObjects:@"object1", @"object2", @"object3", nil];
dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
Das obige Format handelt jedoch nicht nur vom Schlüsselwert. Meine Frage ist also, wie würde dieNSDictionary
sein, das zu passenJSON
Format?? Vielen Dank, dass Sie meinen Beitrag gelesen haben.