NSDictionary to NSDictionary

At the moment, I have the following code to get data from an xml file. It works for now.

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
    attributes:(NSDictionary *)attributeDict{ 
    currentElement = [elementName copy];
    if ([elementName isEqualToString:@"Placemark"]) {
        placemarkData = [[NSMutableDictionary alloc] init];
        currentTitle = [[NSMutableString alloc] init];
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    if ([currentElement isEqualToString:@"name"])
        [placemarkData addObject:string forKey:currentElement];
    if ([currentElement isEqualToString:@"address"])
        [placemarkData addObject:string forKey:currentElement];
    if ([currentElement isEqualToString:@"coordinates"])
        [placemarkData addObject:string forKey:currentElement];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI
 qualifiedName:(NSString *)qName{ 
    if ([elementName isEqualToString:@"Placemark"]) {
        [Placemarks addObject:[placemarkData copy]];
        NSString *batsen = [placemarkData objectForKey:@"name"];
        NSLog(@"adding story: %@", batsen);
    }
}

This dictionary will be loaded into the array. The problem is that where this array was loaded, you need to find the correct entry in the array. I do it like this:

 TabbedCalculationAppDelegate *appDelegate = (TabbedCalculationAppDelegate *)[[UIApplication sharedApplication] delegate];

    NSArray *jean = appDelegate.Placemarks;
    NSDictionary *boekje = [jean objectAtIndex:1];
    NSString *coordinaten = [boekje objectForKey:@"coordinates"];
    NSString *naam = [boekje objectForKey:@"name"];
    NSLog(@"poep: %@" , naam);
    NSLog(@"wwhoppa: %@", coordinaten);
    titel.text = coordinaten;

But since arrays work with an index, I cannot find a way to get the correct record. To clarify, the user clicks on the map in the annotation. This annotation then gets an appropriate detailed view. A detailed view can check which annotation clicks on view.annotation.title;

So I really need a dictionary in the dictionary with the name as the key in the root dictionary. Is it possible? and how can i implement this?

Is that a little clear? Just ask!

Thnx guys

+5
1

, . "" setObject:forKey: "" . . :

NSMutableDictionary *outer=[[NSMutableDictionary alloc] init];
NSDictionary *inner=[NSDictionary dictionaryWithObject:@"hello" forKey:@"world"];
[outer setObject:inner forKey:@"greetings"];
+4

All Articles