Hi,
ich habe eine Frage zum durchsuchen eines NSMutableDictionarys welches in einem NSMutableArray liegt:
In meiner App lese ich die Daten aus einem XML File in ein Dictionary welches ich am Ende jedes Schleifendurchlaufes
in ein NSMutableArray schreibe. Dieses Array verwende ich dann um die Pins auf meiner Karte anzuzeigen. Soweit so
gut - das funktioniert auch super. So sieht mein Code aus um die Pins zu definieren:
Alles anzeigen
CurrentPoint zeigt die UID an - diese ID wird auch beim Klick auf den "Disclosure Button" des Pins angezeigt. Nun müsste ich herausfinden in welcher Zeile des NSMutableArray/NSMutableDictionary
diese UID liegt.
Alles anzeigen
Vielen Dank für Eure Hilfe und Eure Inputs!
lg,
Stefan
ich habe eine Frage zum durchsuchen eines NSMutableDictionarys welches in einem NSMutableArray liegt:
In meiner App lese ich die Daten aus einem XML File in ein Dictionary welches ich am Ende jedes Schleifendurchlaufes
in ein NSMutableArray schreibe. Dieses Array verwende ich dann um die Pins auf meiner Karte anzuzeigen. Soweit so
gut - das funktioniert auch super. So sieht mein Code aus um die Pins zu definieren:
Quellcode
- while (x < [res count]) {
- // NSLog(@"Title: %@", [[res objectAtIndex:x] objectForKey:@"title"]);
- // NSLog(@"Longitude: %@", [[res objectAtIndex:x] objectForKey:@"geo:long"]);
- // NSLog(@"Latitude: %@", [[res objectAtIndex:x] objectForKey:@"geo:lat"]);
- NSLog(@"UID: %d", [NSNumber numberWithInt:[[[res objectAtIndex:x] objectForKey:@"UID"] intValue]]);
- CLLocationCoordinate2D c;
- NSString *latitude = [[res objectAtIndex:x] objectForKey:@"geo:lat"];
- NSString *longitude = [[res objectAtIndex:x] objectForKey:@"geo:long"];
- c.latitude = [latitude doubleValue];
- c.longitude = [longitude doubleValue];
- GPSAnnotation *annotation = [[GPSAnnotation alloc] initWithCoordinate:c];
- annotation.currentPoint = [NSNumber numberWithInt:[[[res objectAtIndex:x] objectForKey:@"UID"] intValue]];
- annotation.mTitle=[[res objectAtIndex:x] objectForKey:@"title"];
- annotation.currentRow = [res objectAtIndex:x];
- [mapViewOutlet addAnnotation:annotation];
- [annotation release];
- x++;
- }
CurrentPoint zeigt die UID an - diese ID wird auch beim Klick auf den "Disclosure Button" des Pins angezeigt. Nun müsste ich herausfinden in welcher Zeile des NSMutableArray/NSMutableDictionary
diese UID liegt.
Quellcode
- - (IBAction)showLinks:(id)sender
- {
- int nrButtonPressed = ((UIButton *)sender).tag; //Liefert die UID des jeweiligen Eintrages
- NSString *find = [NSString stringWithFormat:@"%d", nrButtonPressed]; //Zeigt die UID richtig an
- NSLog(@"find: %@", find);
- NSUInteger index = [res indexOfObject:find]; //Liefert einen äußerst komischen Wert - das NSMutableArray hat 100 Zeilen - angezeigt wird: 2147483647
- NSLog(@"pressed = %i", index);
- NSLog(@"ButtonPressed: %d", nrButtonPressed);
- OnlineMapViewDetailController *controller = [[OnlineMapViewDetailController alloc] initWithNibName:@"OnlineMapViewDetailController" bundle:nil];
- controller.delegate = self;
- controller.pressed = nrButtonPressed;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
Vielen Dank für Eure Hilfe und Eure Inputs!
lg,
Stefan
AlpenApps: Apps fürs Iphone aus Österreich
ACTC - 10.5 & Troubleshooting 10.5
ACTC - 10.5 & Troubleshooting 10.5