Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Code tweaks to work with example Rails app:

Dictionary returned from .json request contained dictionaries by the key
of "goal", so use that object ot populate the goals instead.
  • Loading branch information...
commit 16d94bd41f62e0440d686ce0d4a28b08d5bb1dc8 1 parent e6f7ba5
Clint authored November 22, 2010
2  code/2-json/Classes/Goal.m
@@ -47,7 +47,7 @@ + (NSArray *)findAllRemote {
47 47
         [json release];
48 48
         
49 49
         for (NSDictionary *dictionary in results) {
50  
-            Goal *goal = [[Goal alloc] initWithDictionary:dictionary];
  50
+			Goal *goal = [[Goal alloc] initWithDictionary:[dictionary valueForKey:@"goal"]];
51 51
             [goals addObject:goal];
52 52
             [goal release];
53 53
         }
8  workbook/html/json.html
@@ -116,7 +116,7 @@
116 116
 
117 117
 - (id)initWithDictionary:(NSDictionary *)dictionary;
118 118
 
119  
-+ (NSArray *)findAllRemote;
  119
++ (NSMutableArray *)findAllRemote;
120 120
 
121 121
 @end
122 122
 
@@ -167,7 +167,7 @@
167 167
 <div class="slide"><h1 class="exercise">3. Add a Goal Finder Method</h1>
168 168
 <p class="first">Send a <span class="caps">GET</span> request, parse the <span class="caps">JSON</span> response, and create <code>Goal</code> objects:</p>
169 169
 <div class="code-small">
170  
-<pre name="code" class="brush: ruby">+ (NSArray *)findAllRemote {
  170
+<pre name="code" class="brush: ruby">+ (NSMutableArray *)findAllRemote {
171 171
     NSURL *url = [NSURL URLWithString:@"http://localhost:3000/goals.json"];
172 172
     
173 173
     NSError *error = nil;
@@ -184,7 +184,7 @@
184 184
         [json release];
185 185
         
186 186
         for (NSDictionary *dictionary in results) {
187  
-            Goal *goal = [[Goal alloc] initWithDictionary:dictionary];
  187
+            Goal *goal = [[Goal alloc] initWithDictionary:[dictionary valueForKey:@"goal"]];
188 188
             [goals addObject:goal];
189 189
             [goal release];
190 190
         }
@@ -218,7 +218,7 @@
218 218
 <div class="slide"><h1 class="exercise">5. Configure the Table Cells</h1>
219 219
 <p class="first">Change each row to contain the respective goal&#8217;s name and amount:</p>
220 220
 <div class="code-medium">
221  
-<pre name="code" class="brush: ruby; highlight: [13,14,15,16]">    Goal *goal = [goals objectAtIndex:indexPath.row];
  221
+<pre name="code" class="brush: ruby; highlight: [13,14,15,16]">    Goal *goal = [self.goals objectAtIndex:indexPath.row];
222 222
     
223 223
     cell.textLabel.text = goal.name;
224 224
     cell.detailTextLabel.text = goal.amount;

0 notes on commit 16d94bd

Please sign in to comment.
Something went wrong with that request. Please try again.