Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding key/value Pairs results in keys with null values
    primarykey
    data
    text
    <p>I'm having an issue that the dictionary <code>timeStamps</code> changes all the values to <code>null</code>. The keys are all fine, even if I switch what was a key to a value and vice versa. No matter the order, the values end up as <code>null</code> and the keys end up exactly as they should.</p> <p>Here's the code. It's an xml parser. It is building a dictionary that has an array of codes for keys and an array of timestamps for values. The keys and values are parallel arrays representing categories. </p> <p>All variables are allocated and initiated elsewhere. This imports the header file that has all of these variables as properties. <code>@property (strong, nonatomic) Type variableName;</code> then in the main file it has the line <code>@synthesize variableName</code>. Also, it has <code>variableName = [[Type alloc] init];</code>. Thank you everybody for your help!</p> <pre><code>- (void) didStartElement (elementname is passed as xml tag) { //Tells us if we are in the dance categories if ([elementName isEqualToString:@"categories"]) { isCategory = YES; // Just tells us we're ready to start reading } else if ([elementName isEqualToString:@"category"] &amp;&amp; isCategory) { onCategory = YES; // } } - (void) foundCharacters (currentNodeContent is the info between tags) { currentNodeContent = (NSMutableString *) string; } - (void) didEndElement { // if leaving dance categories if ([elementName isEqualToString:@"Category End"]) { isCategory = NO; // We've left a category } else if ([elementName isEqualToString:@"code"] &amp;&amp; onCategory) { Code = currentNodeContent; currentNodeContent = nil; isWaitingForTime = YES; } else if ([elementName isEqualToString:@"time"] &amp;&amp; isWaitingForTime) { [runningList addObject:Code]; [runningList addObject:currentNodeContent]; isWaitingForTime = NO; currentNodeContent = nil; Code = @""; } else if ([elementName isEqualToString:@"dances"]) { [timeStamps setObject:runningTimeList forKey:runningList]; [runningTimeList removeAllObjects]; [runningList removeAllObjects]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload