Skip to content

Commit f549bec

Browse files
committed
dispatch async the handler in the main queue
1 parent b3051dd commit f549bec

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ before_install:
77
- gem install xcpretty -N
88
script:
99
- set -o pipefail
10-
- xcodebuild -project AlgoliaSearch.xcodeproj -scheme "AlgoliaSearch iOS" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 6" ONLY_ACTIVE_ARCH=NO test | xcpretty -c
1110
- xcodebuild -project AlgoliaSearch.xcodeproj -scheme "AlgoliaSearch OSX" test | xcpretty -c

Source/Network.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class Manager {
5454

5555
var dataTask = session.dataTaskWithRequest(URLRequest, completionHandler: { (data, response, error) -> Void in
5656
let (JSON: AnyObject?, _) = self.serializeResponse(data)
57-
block(response as? NSHTTPURLResponse, JSON, error)
57+
dispatch_async(dispatch_get_main_queue()) {
58+
block(response as? NSHTTPURLResponse, JSON, error)
59+
}
5860
})
5961

6062
let request = Request(session: session, task: dataTask)

Tests/IndexTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class IndexTests: XCTestCase {
9393
func testAddWithObjectID() {
9494
let expectation = expectationWithDescription("testAddWithObjectID")
9595
let object = ["city": "San José"]
96-
let objectID = "a/go/?à-2"
96+
let objectID = "a/go/?à"
9797

9898
index.addObject(object, withID: objectID, block: { (JSON, error) -> Void in
9999
if let error = error {
@@ -184,7 +184,7 @@ class IndexTests: XCTestCase {
184184

185185
func testDelete() {
186186
let expectation = expectationWithDescription("testDelete")
187-
let object = ["city": "Las Vegas", "objectID": "a/go/?à-3"]
187+
let object = ["city": "Las Vegas", "objectID": "a/go/?à"]
188188

189189
index.addObject(object, block: { (JSON, error) -> Void in
190190
if let error = error {
@@ -265,7 +265,7 @@ class IndexTests: XCTestCase {
265265

266266
func testGet() {
267267
let expectation = expectationWithDescription("testGet")
268-
let object = ["city": "Los Angeles", "objectID": "a/go/?à-4"]
268+
let object = ["city": "Los Angeles", "objectID": "a/go/?à"]
269269

270270
index.addObject(object, block: { (JSON, error) -> Void in
271271
if let error = error {
@@ -333,7 +333,7 @@ class IndexTests: XCTestCase {
333333

334334
func testPartialUpdateObject() {
335335
let expectation = expectationWithDescription("testPartialUpdateObject")
336-
let object = ["city": "New York", "initial": "NY", "objectID": "a/go/?à-5"]
336+
let object = ["city": "New York", "initial": "NY", "objectID": "a/go/?à"]
337337

338338
index.addObject(object, block: { (JSON, error) -> Void in
339339
if let error = error {
@@ -423,14 +423,14 @@ class IndexTests: XCTestCase {
423423

424424
func testSaveObject() {
425425
let expectation = expectationWithDescription("testSaveObject")
426-
let object = ["city": "New York", "initial": "NY", "objectID": "a/go/?à-6"]
426+
let object = ["city": "New York", "initial": "NY", "objectID": "a/go/?à"]
427427

428428
index.addObject(object, block: { (JSON, error) -> Void in
429429
if let error = error {
430430
XCTFail("Error during addObject: \(error)")
431431
expectation.fulfill()
432432
} else {
433-
self.index.saveObject(["city": "Los Angeles", "objectID": "a/go/?à-6"], block: { (JSON, error) -> Void in
433+
self.index.saveObject(["city": "Los Angeles", "objectID": "a/go/?à"], block: { (JSON, error) -> Void in
434434
if let error = error {
435435
XCTFail("Error during saveObject: \(error)")
436436
expectation.fulfill()
@@ -618,7 +618,7 @@ class IndexTests: XCTestCase {
618618
let expectation = expectationWithDescription("testBrowseWithHitsPerPage")
619619
let objects = [
620620
["city": "San Francisco", "objectID": "a/go/?à"],
621-
["city": "New York", "objectID": "a/go/?à-1"]
621+
["city": "New York", "objectID": "a/go/?à$"]
622622
]
623623

624624
index.addObjects(objects, block: { (JSON, error) -> Void in

0 commit comments

Comments
 (0)