Skip to content

Commit e5bc295

Browse files
author
Josh Holtz
committed
Update README.md
1 parent 7fe82e9 commit e5bc295

File tree

1 file changed

+0
-77
lines changed

1 file changed

+0
-77
lines changed

README.md

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -178,83 +178,6 @@ for (JSONAPIResource *post in posts) {
178178
179179
````
180180

181-
### Parsing - Using linked resources and subclassed JSONAPIResource classes
182-
183-
```` objc
184-
185-
NSString *json = @"{\"posts\":[{\"id\":1,\"name\":\"A post!\",\"links\":{\"author\":9}},{\"id\":2,\"name\":\"Another post!\",\"links\":{\"author\":10}}],\"linked\":{\"people\":[{\"id\":9,\"name\":\"Josh Holtz\"},{\"id\":10,\"name\":\"Bandit the Cat\"}]}}";
186-
187-
// Links "author" resource to "people" linked resources
188-
[JSONAPIResourceLinker link:@"author" toLinkedType:@"people"];
189-
190-
// Loads "people" into `PeopleResource` and "posts" into `PostResource`
191-
[JSONAPIResourceModeler useResource:[PeopleResource class] toLinkedType:@"people"];
192-
[JSONAPIResourceModeler useResource:[PostResource class] toLinkedType:@"posts"];
193-
194-
// Parses JSON string into JSONAPI object
195-
JSONAPI *jsonApi = [JSONAPI JSONAPIWithString:json];
196-
197-
// Gets posts from JSONAPI that will be an array of PostResource objects
198-
NSArray *posts = [jsonApi resourcesForKey:@"posts"];
199-
200-
// Parsing using JSONAPI and modeled resources (PostResource, PeopleResource, CommentResource
201-
for (PostResource *post in posts) {
202-
203-
PeopleResource *author = post.author;
204-
NSLog(@"\"%@\" by %@", post.name, author.name);
205-
}
206-
207-
````
208-
209-
#### PostResource.h, PostResource.m
210-
211-
```` objc
212-
213-
@interface PostResource : JSONAPIResource
214-
215-
- (PeopleResource*)author;
216-
- (NSString*)name;
217-
218-
@end
219-
220-
@implementation PostResource
221-
222-
- (PeopleResource *)author {
223-
return [self linkedResourceForKey:@"author"];
224-
}
225-
226-
- (NSArray *)comments {
227-
return [self linkedResourceForKey:@"comments"];
228-
}
229-
230-
- (NSString *)name {
231-
return [self objectForKey:@"name"];
232-
}
233-
234-
@end
235-
236-
````
237-
238-
#### PeopleResource.h, PeopleResource.m
239-
240-
```` objc
241-
242-
@interface PeopleResource : JSONAPIResource
243-
244-
- (NSString*)name;
245-
246-
@end
247-
248-
@implementation PeopleResource
249-
250-
- (NSString *)name {
251-
return [self objectForKey:@"name"];
252-
}
253-
254-
@end
255-
256-
````
257-
258181
### Parsing - Using linked resources, subclassed JSONAPIResource classes, and model mappings
259182
This example shows how a response can be mapped directly into properties of a sublcasses JSONAPIResource
260183

0 commit comments

Comments
 (0)