Skip to content

Commit

Permalink
migrate to Swift 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlui committed Jul 15, 2015
1 parent 2a1ad8b commit 2f0beee
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Pitaya/Pitaya.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
463711FC1B04C2050019E1AB /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = "http://lvwenhan.com";
TargetAttributes = {
Expand Down
8 changes: 4 additions & 4 deletions Pitaya/Pitaya/Pitaya.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension String {
}
var base64: String! {
let utf8EncodeData: NSData! = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
let base64EncodingData = utf8EncodeData.base64EncodedStringWithOptions(nil)
let base64EncodingData = utf8EncodeData.base64EncodedStringWithOptions([])
return base64EncodingData
}
}
Expand All @@ -27,11 +27,11 @@ public func request(method: HTTPMethod, url: String, params: Dictionary<String,
let pitaya = PitayaManager(url: url, method: method, params: params, errorCallback: errorCallback, callback: callback)
pitaya.fire()
}
public func request(method: HTTPMethod, url: String, files: Array<File> = Array<File>(), errorCallback: (error: NSError) -> Void, callback:(string: String) -> Void) {
public func request(method: HTTPMethod, url: String, files: Array<File>, errorCallback: (error: NSError) -> Void, callback:(string: String) -> Void) {
let pitaya = PitayaManager(url: url, method: method, files: files, errorCallback: errorCallback, callback: callback)
pitaya.fire()
}
public func request(method: HTTPMethod, url: String, params: Dictionary<String, AnyObject>, files: Array<File> = Array<File>(), errorCallback: (error: NSError) -> Void, callback:(string: String) -> Void) {
public func request(method: HTTPMethod, url: String, params: Dictionary<String, AnyObject>, files: Array<File>, errorCallback: (error: NSError) -> Void, callback:(string: String) -> Void) {
let pitaya = PitayaManager(url: url, method: method, params: params, files: files, errorCallback: errorCallback, callback: callback)
pitaya.fire()
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public class PitayaManager {
// stolen from Alamofire
func buildParams(parameters: [String: AnyObject]) -> String {
var components: [(String, String)] = []
for key in sorted(Array(parameters.keys), <) {
for key in Array(parameters.keys).sort(<) {
let value: AnyObject! = parameters[key]
components += self.queryComponents(key, value)
}
Expand Down
2 changes: 2 additions & 0 deletions PitayaExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@
46C7CAB41B04AA4000CC3B70 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = "http://lvwenhan.com";
TargetAttributes = {
Expand Down
Binary file not shown.
14 changes: 7 additions & 7 deletions PitayaExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ class ViewController: UIViewController {
}

@IBAction func mainButtonBeTapped(sender: AnyObject) {
Pitaya.request(.GET, "http://pitayaswift.sinaapp.com/pitaya.php", { (error) -> Void in
Pitaya.request(.GET, url: "http://pitayaswift.sinaapp.com/pitaya.php", errorCallback: { (error) -> Void in
NSLog(error.localizedDescription)
}) { (string) -> Void in
println(string)
print(string)
}
Pitaya.request(.POST, "http://pitayaswift.sinaapp.com/pitaya.php", ["post": "pitaya"], { (error) -> Void in
Pitaya.request(.POST, url: "http://pitayaswift.sinaapp.com/pitaya.php", params: ["post": "pitaya"], errorCallback: { (error) -> Void in
NSLog(error.localizedDescription)
}) { (string) -> Void in
println(string)
print(string)
}
let file = File(name: "file", url: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("Pitaya", ofType: "png")!)!)
Pitaya.request(.POST, "http://pitayaswift.sinaapp.com/pitaya.php", files: [file], { (error) -> Void in
let file = File(name: "file", url: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("Pitaya", ofType: "png")!))
Pitaya.request(.POST, url: "http://pitayaswift.sinaapp.com/pitaya.php", files: [file], errorCallback: { (error) -> Void in
NSLog(error.localizedDescription)
}) { (string) -> Void in
println(string)
print(string)
}
}

Expand Down

0 comments on commit 2f0beee

Please sign in to comment.