This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Result | |
import ReactiveCocoa | |
import Foundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
let postsProducer = SignalProducer<AnyObject, NSError> { observer, disposable in | |
let url = NSURL(string:"http://jsonplaceholder.typicode.com/posts")!.URLByAppendingPathComponent("42") | |
let task = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getUserPosts(userID:String) -> SignalProducer<AnyObject, NSError> { | |
let postsProducer = SignalProducer<AnyObject, NSError> { observer, disposable in | |
let url = NSURL(string:"http://jsonplaceholder.typicode.com/posts")!.URLByAppendingPathComponent(userID) | |
let task = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) in | |
if error != nil { | |
observer.sendFailed(NSError(domain:"", code:5, userInfo:nil)) | |
} else { | |
let json = try! NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions()) | |
observer.sendNext(json) | |
observer.sendCompleted() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Result | |
import ReactiveCocoa | |
import Foundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
let producer1 = SignalProducer<AnyObject, NSError> { observer, disposable in | |
let task1 = NSURLSession.sharedSession().dataTaskWithURL(NSURL(string:"http://jsonplaceholder.typicode.com/posts/1")!, completionHandler: { (data, response, error) in | |
if error != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git remote add hemet https://github.com/HeMet/swift-corelibs-foundation.git # add the contributor's repo as a remote | |
$ git remote update # grab the contributor's repo refs | |
$ git rebase origin/master master # update your local master branch to be up to date with origin | |
$ git checkout -b PR213 hemet/nsurl-fixes # make a local branch for the PR | |
$ git rebase master # rebase the PR branch on the most up to date master | |
$ git checkout master | |
$ git merge PR213 # fast-forward merge the PR branch on master | |
$ git push origin master # update master on the main repo | |
$ git branch -D PR213 # delete the PR branch from your local | |
$ git remote remove hemet # delete the contributor's repo remote |