Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The capacity is merely how many objects a container class can hold. Inserting at an index requires that index to be a valid placement for the new object based on the total number of objects contained in the container (not the total number of objects that CAN be contained).</p> <p>If your array's values are index dependent (which is seems like perhaps a different architecture or data structure would be better) then you can ensure that every index is filled by prepopulating the array with NSNulls. This would require you to check for NSNulls when reading from the array later on though which would likely be extra work, hence why this is probably not the best approach. In any case, you can change your code to the following to fix your crash.</p> <pre><code>factsBuiltArray = [NSMutableArray arrayWithCapacity: 6]; for (NSUInter i = 0; i &lt; 6; i++) { [factsBuiltArray addObject:[NSNull null]]; } if ([statusDict count] == 10) { for (NSString *key in [statusDict allKeys]) { if ([key isEqualToString: @"currenciesAndConversions"]) { [factsBuiltArray replaceObjectAtIndex:0 withObject:key]; } else if ([key isEqualToString: @"languageAndTranslations"]) { [factsBuiltArray replaceObjectAtIndex:1 withObject:key]; } else if ([key isEqualToString: @"plugSize"]) { [factsBuiltArray replaceObjectAtIndex:2 withObject:key]; } else if ([key isEqualToString: @"timezone"]) { [factsBuiltArray replaceObjectAtIndex:3 withObject:key]; } else if ([key isEqualToString: @"population"]) { [factsBuiltArray replaceObjectAtIndex:4 withObject:key]; } else if ([key isEqualToString: @"wikipedia"]) { [factsBuiltArray replaceObjectAtIndex:5 withObject:key]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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