Skip to content

Commit a846c40

Browse files
committed
Post requests
1 parent ad1fc57 commit a846c40

File tree

4 files changed

+91
-20
lines changed

4 files changed

+91
-20
lines changed

TestSwift.xcodeproj/project.pbxproj

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@
2121
/* End PBXBuildFile section */
2222

2323
/* Begin PBXContainerItemProxy section */
24+
021E1B2B1944FCF700FDC37C /* PBXContainerItemProxy */ = {
25+
isa = PBXContainerItemProxy;
26+
containerPortal = 021E1B261944FCF700FDC37C /* SwiftNetworking.xcodeproj */;
27+
proxyType = 2;
28+
remoteGlobalIDString = 021E1AFE1944F5A300FDC37C;
29+
remoteInfo = SwiftNetworking;
30+
};
31+
021E1B2D1944FCF700FDC37C /* PBXContainerItemProxy */ = {
32+
isa = PBXContainerItemProxy;
33+
containerPortal = 021E1B261944FCF700FDC37C /* SwiftNetworking.xcodeproj */;
34+
proxyType = 2;
35+
remoteGlobalIDString = 021E1B091944F5A400FDC37C;
36+
remoteInfo = SwiftNetworkingTests;
37+
};
38+
021E1B2F1944FD1500FDC37C /* PBXContainerItemProxy */ = {
39+
isa = PBXContainerItemProxy;
40+
containerPortal = 021E1B261944FCF700FDC37C /* SwiftNetworking.xcodeproj */;
41+
proxyType = 1;
42+
remoteGlobalIDString = 021E1AFD1944F5A300FDC37C;
43+
remoteInfo = SwiftNetworking;
44+
};
2445
02CCF4B5193D16930069AEE9 /* PBXContainerItemProxy */ = {
2546
isa = PBXContainerItemProxy;
2647
containerPortal = 02CCF49A193D16930069AEE9 /* Project object */;
@@ -33,6 +54,7 @@
3354
/* Begin PBXFileReference section */
3455
021E1AEE1944CDDE00FDC37C /* Track.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Track.swift; path = Classes/Track.swift; sourceTree = "<group>"; };
3556
021E1AF01944D4A800FDC37C /* TrackCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackCell.swift; sourceTree = "<group>"; };
57+
021E1B261944FCF700FDC37C /* SwiftNetworking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SwiftNetworking.xcodeproj; path = ../../SwiftNetworking/SwiftNetworking.xcodeproj; sourceTree = "<group>"; };
3658
022889EE193FC3AC00D729A0 /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DetailsViewController.swift; path = Classes/DetailsViewController.swift; sourceTree = "<group>"; };
3759
022889F0193FD6C000D729A0 /* Album.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Album.swift; path = Classes/Album.swift; sourceTree = "<group>"; };
3860
0229AE62193F97EF00BCED97 /* Blank52.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Blank52.png; sourceTree = "<group>"; };
@@ -103,6 +125,15 @@
103125
name = Graphics;
104126
sourceTree = "<group>";
105127
};
128+
021E1B271944FCF700FDC37C /* Products */ = {
129+
isa = PBXGroup;
130+
children = (
131+
021E1B2C1944FCF700FDC37C /* SwiftNetworking.framework */,
132+
021E1B2E1944FCF700FDC37C /* SwiftNetworkingTests.xctest */,
133+
);
134+
name = Products;
135+
sourceTree = "<group>";
136+
};
106137
02CCF499193D16930069AEE9 = {
107138
isa = PBXGroup;
108139
children = (
@@ -124,6 +155,7 @@
124155
02CCF4A4193D16930069AEE9 /* TestSwift */ = {
125156
isa = PBXGroup;
126157
children = (
158+
021E1B261944FCF700FDC37C /* SwiftNetworking.xcodeproj */,
127159
021E1AED1944CCA800FDC37C /* Graphics */,
128160
021E1AEC1944CC9500FDC37C /* REST */,
129161
021E1AEB1944CC8D00FDC37C /* Model */,
@@ -175,6 +207,7 @@
175207
buildRules = (
176208
);
177209
dependencies = (
210+
021E1B301944FD1500FDC37C /* PBXTargetDependency */,
178211
);
179212
name = TestSwift;
180213
productName = TestSwift;
@@ -228,6 +261,12 @@
228261
mainGroup = 02CCF499193D16930069AEE9;
229262
productRefGroup = 02CCF4A3193D16930069AEE9 /* Products */;
230263
projectDirPath = "";
264+
projectReferences = (
265+
{
266+
ProductGroup = 021E1B271944FCF700FDC37C /* Products */;
267+
ProjectRef = 021E1B261944FCF700FDC37C /* SwiftNetworking.xcodeproj */;
268+
},
269+
);
231270
projectRoot = "";
232271
targets = (
233272
02CCF4A1193D16930069AEE9 /* TestSwift */,
@@ -236,6 +275,23 @@
236275
};
237276
/* End PBXProject section */
238277

278+
/* Begin PBXReferenceProxy section */
279+
021E1B2C1944FCF700FDC37C /* SwiftNetworking.framework */ = {
280+
isa = PBXReferenceProxy;
281+
fileType = wrapper.framework;
282+
path = SwiftNetworking.framework;
283+
remoteRef = 021E1B2B1944FCF700FDC37C /* PBXContainerItemProxy */;
284+
sourceTree = BUILT_PRODUCTS_DIR;
285+
};
286+
021E1B2E1944FCF700FDC37C /* SwiftNetworkingTests.xctest */ = {
287+
isa = PBXReferenceProxy;
288+
fileType = wrapper.cfbundle;
289+
path = SwiftNetworkingTests.xctest;
290+
remoteRef = 021E1B2D1944FCF700FDC37C /* PBXContainerItemProxy */;
291+
sourceTree = BUILT_PRODUCTS_DIR;
292+
};
293+
/* End PBXReferenceProxy section */
294+
239295
/* Begin PBXResourcesBuildPhase section */
240296
02CCF4A0193D16930069AEE9 /* Resources */ = {
241297
isa = PBXResourcesBuildPhase;
@@ -282,6 +338,11 @@
282338
/* End PBXSourcesBuildPhase section */
283339

284340
/* Begin PBXTargetDependency section */
341+
021E1B301944FD1500FDC37C /* PBXTargetDependency */ = {
342+
isa = PBXTargetDependency;
343+
name = SwiftNetworking;
344+
targetProxy = 021E1B2F1944FD1500FDC37C /* PBXContainerItemProxy */;
345+
};
285346
02CCF4B6193D16930069AEE9 /* PBXTargetDependency */ = {
286347
isa = PBXTargetDependency;
287348
target = 02CCF4A1193D16930069AEE9 /* TestSwift */;
@@ -386,9 +447,14 @@
386447
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
387448
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
388449
CLANG_ENABLE_MODULES = YES;
450+
FRAMEWORK_SEARCH_PATHS = (
451+
"$(inherited)",
452+
/Users/jquave/Code/libs,
453+
);
389454
INFOPLIST_FILE = TestSwift/Info.plist;
390455
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
391456
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
457+
LIBRARY_SEARCH_PATHS = /Users/jquave/Code/lib;
392458
PRODUCT_NAME = "$(TARGET_NAME)";
393459
SWIFT_OBJC_BRIDGING_HEADER = "TestSwift/TestSwift-Bridging-Header.h";
394460
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -401,9 +467,14 @@
401467
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
402468
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
403469
CLANG_ENABLE_MODULES = YES;
470+
FRAMEWORK_SEARCH_PATHS = (
471+
"$(inherited)",
472+
/Users/jquave/Code/libs,
473+
);
404474
INFOPLIST_FILE = TestSwift/Info.plist;
405475
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
406476
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
477+
LIBRARY_SEARCH_PATHS = /Users/jquave/Code/lib;
407478
PRODUCT_NAME = "$(TARGET_NAME)";
408479
SWIFT_OBJC_BRIDGING_HEADER = "TestSwift/TestSwift-Bridging-Header.h";
409480
};

TestSwift/APIController.swift

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import SwiftNetworking
1011

1112
protocol APIControllerProtocol {
1213
func didRecieveAPIResults(results: NSDictionary)
@@ -21,25 +22,10 @@ class APIController {
2122
}
2223

2324
func get(path: String) {
24-
let url = NSURL(string: path)
25-
let request = NSURLRequest(URL: url)
26-
27-
println("Get \(path)")
28-
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in
29-
if error? {
30-
println("ERROR: \(error.localizedDescription)")
31-
}
32-
else {
33-
var error: NSError?
34-
let jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary
35-
// Now send the JSON result to our delegate object
36-
if error? {
37-
println("HTTP Error: \(error?.localizedDescription)")
38-
}
39-
else {
40-
println("Results recieved")
41-
self.delegate?.didRecieveAPIResults(jsonResult)
42-
}
25+
var sn = SwiftNetworking()
26+
sn.get(path, completionHandler: {(result: AnyObject) -> Void in
27+
if let dict = result as? NSDictionary {
28+
self.delegate?.didRecieveAPIResults(dict)
4329
}
4430
})
4531
}

TestSwift/AppDelegate.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import SwiftNetworking
1011

1112
@UIApplicationMain
1213
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -15,6 +16,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1516

1617

1718
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
19+
20+
var sn = SwiftNetworking()
21+
22+
var params = ["user\"name":"jquave","password":"myPass"]
23+
sn.post("http://localhost:3000/api/register", params: params, completionHandler: {(result: AnyObject) -> Void in
24+
println(result)
25+
})
26+
27+
28+
29+
sn.get("", completionHandler: {(result: AnyObject) -> Void in
30+
if let dict = result as? NSDictionary {
31+
}
32+
})
1833

1934
return true
2035
}

TestSwift/SearchResultsViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
4242

4343
func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) {
4444
cell.layer.transform = CATransform3DMakeScale(0.1,0.1,1)
45-
4645
UIView.beginAnimations("animInCell", context: nil)
4746
cell.layer.transform = CATransform3DMakeScale(1,1,1)
4847
UIView.commitAnimations()

0 commit comments

Comments
 (0)