Finden Dictionary-Schlüssel in Array von Dictionaries

Ich habe ein array, hält mehrere NSMutableDictionary Objekte.

Jedes mal, wenn text-Felder sind ausgefüllt und der submit-button gedrückt wird:

//The strings
NSString *dateString = @"Date";
NSString *timeString = @"Time";
NSString *typeString = @"Type";

- (IBAction)addData:(id)sender {

[_myDictionary setObject:_dateLabel.text forKey:dateString];
[_myDictionary setObject:_nNumber.text forKey:timeString];
[_myDictionary setObject:_type.text forKey:typeString];

[_myArray addObject:_myDictionary];

[self display]
}

Dann bin ich versucht, die Anzeige der Ergebnisse in einem UItextView (in diesem Beispiel das Datum), aber ich weiß nicht, wie.

    -(void)displayData{

    for (int i = 0; i<_myArray.count; i++) {
        [_myArray objectAtIndex:i];
        outputString = [outputString stringByAppendingFormat:@"%@\n",[_myDictionary objectForKey:@"Date"]];

    }
    _myTextView.text = [NSString stringWithFormat:@"%@",outputString];

}

Endet die Anzeige der Termin für das Letzte Wörterbuch in das array. Ich kann nicht einmal herausfinden, wie Sie sich das Datum aus einem bestimmten Wörterbuch.
Sagen [_myArray objectAtIndex:3] [_myDictionary objectForKey:@"Date"]. Wie würde ich das Protokoll das Datum vom 3. index?

Hoffe, das macht Sinn

EDIT SOLUTION

for (int i = 0; i<_myArray.count; i++)
    {

        outputString = [outputString stringByAppendingFormat:@"%@ %@\n",[[_myArray objectAtIndex:i]objectForKey:@"Date"], [[_myArray objectAtIndex:i]objectForKey:@"Time"]];

    }
    _myTextView.text = [NSString stringWithFormat:@"%@",outputString];

}

Danke für die schnelle Hilfe!!

InformationsquelleAutor Gulfer | 2013-05-01

Schreibe einen Kommentar