Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><code>tide.tideSummaryStats</code> returns an array. </li> <li><code>tide.tideInfo</code> returns an array.</li> </ol> <p>So you can't do <code>-valueForKeyPath:</code> all the way.</p> <hr> <p>Also, this is incorrect: <code>[dictionary valueForKeyPath:...];</code><br> it should be : <code>[json valueForKeyPath:...];</code></p> <p>because <code>json</code> is the name of the <code>NSDictionary</code> variable passed (<em>not <code>dictionary</code></em>)</p> <hr> <p>Try this (<em>not sure</em>):</p> <pre><code>-(id)initWithDict:(NSDictionary *)json { self = [super init]; if(self) { NSArray *arrOfTideSummaryStats = [json valueForKeyPath:@"tide.tideSummaryStats"]; NSDictionary *dctOfTideSummaryStats = [arrOfTideSummaryStats objectAtIndex:0]; //since self.maxheight and self.minheight are NSString objects and //the original keys "minheight" &amp; "maxheight" return float values, do: self.maxheight = [NSString stringWithFormat:@"%f", [dctOfTideSummaryStats valueForKey: @"maxheight"]]; self.minheight = [NSString stringWithFormat:@"%f", [dctOfTideSummaryStats valueForKey: @"minheight"]]; /*============================================================*/ NSArray *arrOfTideInfo = [json valueForKeyPath:@"tide.tideInfo"]; NSDictionary *dctOfTideInfo = [arrOfTideInfo objectAtIndex:0]; self.tideSite = [dctOfTideInfo valueForKey:@"tideSite"]; } return self; } </code></pre> <hr> <p>Similar Questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/3165290/how-to-parsing-json-object-in-iphone-sdk-xcode-using-json-framework">How to parsing JSON object in iPhone SDK (XCode) using JSON-Framework</a></li> <li><a href="https://stackoverflow.com/questions/1461126/getting-array-elements-with-valueforkeypath">Getting array elements with valueForKeyPath</a></li> <li><a href="https://stackoverflow.com/questions/12054846/keypath-for-first-element-in-embedded-nsarray">Keypath for first element in embedded NSArray</a></li> </ul>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. 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