Skip to content

Commit

Permalink
Readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Wes Billman committed May 20, 2017
1 parent f88df37 commit e5ef3aa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,32 @@ let feed = try? JSONFeed(data: data)
let string = <some utf8 json string>
let feed = try? JSONFeed(string: string)
```
### Reading from a feed via URLSession

Using default configuration and URLSession
```swift
let reader = JSONFeedReader()
reader.read(string: "https://jsonfeed.org/feed.json") { (feed, error) in
if let error = error {
//bad things happened
}

if let feed = feed {
//good things happened
}
}
```

Using custom implemenation of URLSession (example: for unit testing)
```swift
let reader = JSONFeedReader(session: SomeCustomURLSession)
reader.read(string: "https://jsonfeed.org/feed.json") { (feed, error) in
if let error = error {
//bad things happened
}

if let feed = feed {
//good things happened
}
}
```

0 comments on commit e5ef3aa

Please sign in to comment.