Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:09:59+00:00 2026-05-27T18:09:59+00:00

I would like to pass the nsdictionary I am creating into an nsmutablearray but

  • 0

I would like to pass the nsdictionary I am creating into an nsmutablearray but I’m not sure when or how to do it in the nsxmlparser delegates.

this is what I have done so far

#pragma mark - Parsing lifecycle

- (void)startTheParsingProcess:(NSData *)parserData
{    
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //parserData passed to NSXMLParser delegate which starts the parsing process 

    [parser setDelegate:self];
    [parser parse]; // starts the event-driven parsing operation.
}


- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict 
{
    if ([elementName isEqualToString:@"item"]) {
        valueDictionary = [[NSMutableDictionary alloc] init];
    }    
}

-(void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
{
    NSMutableString *dicString = [[NSMutableString alloc] initWithData:CDATABlock encoding:NSUTF8StringEncoding];
    currentElement = dicString;
}



- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
{
    if ([elementName isEqualToString:@"title"]) {
        titleString = currentElement;
        [self.valueDictionary setObject:titleString forKey:@"title"];

        NSLog(@"%@", [valueDictionary objectForKey:@"title"]);
        NSLog(@" ");
        currentElement = nil;
    }
    if ([elementName isEqualToString:@"description"]) 
    {
        descriptionString = currentElement;
        [self.valueDictionary setObject:descriptionString forKey:@"description"];

        NSLog(@"%@", [valueDictionary objectForKey:@"description"]);
        NSLog(@" ");
        currentElement = nil;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:10:00+00:00Added an answer on May 27, 2026 at 6:10 pm

    In -parser:didEndElement:namespaceURI:qualifiedName:, listen for the end of the item element, then add valueDictionary to a mutable array instance on your class.

    if ([elementName isEqualToString:@"item"])
    {
        [self.mutableArrayOfDictionaries addObject:self.valueDictionary];
    }
    
    if ([elementName isEqualToString:@"title"]) {
        titleString = currentElement;
        [self.valueDictionary setObject:titleString forKey:@"title"];
    
        NSLog(@"%@", [valueDictionary objectForKey:@"title"]);
        NSLog(@" ");
        currentElement = nil;
    }
    
    if ([elementName isEqualToString:@"description"]) 
    {
        descriptionString = currentElement;
        [self.valueDictionary setObject:descriptionString forKey:@"description"];
    
        NSLog(@"%@", [valueDictionary objectForKey:@"description"]);
        NSLog(@" ");
        currentElement = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some variables that I would like to pass into an AJAX call:
I would like to pass a reference of a method into another method and
I would like to pass values into the constructor on the class that implements
I would like to pass custom options into my field. Is there a way
I would like to pass a NSMutableArray by reference so that it can be
I have a stored procedure that I would like to pass a string to,
I have a UserControl named BreadCrumb. I would like to pass in information to
I would like to pass Variables from my package into Script Transformation Editor. How
I would like to pass some options to a compiler. The option would have
I would like to pass parameters into a stored procedure in SQL Server 2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.