Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d183712

Browse files
committed
More explicit blog featured/favorites checking
1 parent 5b92bd7 commit d183712

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

HypeMachineAPI.playground/Contents.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import XCPlayground
22
import Foundation
33
import HypeMachineAPI
44

5+
56
// Allow network requests to complete
67
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
78

89
func callback(result: Result<[Blog]>) {
9-
print(result)
10+
print(result.value!.filter { $0.following == true }.count)
11+
print(result.value!.filter { $0.featured == true }.count)
1012
}
1113

12-
HypeMachineAPI.Requests.Blogs.index(optionalParams: nil, callback: callback)
14+
HypeMachineAPI.Requests.Blogs.index(optionalParams: nil, callback: callback)

HypeMachineAPI.playground/timeline.xctimeline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
version = "3.0">
44
<TimelineItems>
55
<LoggerValueHistoryTimelineItem
6-
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=221&amp;EndingColumnNumber=25&amp;EndingLineNumber=6&amp;StartingColumnNumber=9&amp;StartingLineNumber=6&amp;Timestamp=471293286.469673"
6+
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=329&amp;EndingColumnNumber=25&amp;EndingLineNumber=7&amp;StartingColumnNumber=9&amp;StartingLineNumber=7&amp;Timestamp=471298613.499679"
77
selectedRepresentationIndex = "0"
88
shouldTrackSuperviewWidth = "NO">
99
</LoggerValueHistoryTimelineItem>
1010
<LoggerValueHistoryTimelineItem
11-
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=221&amp;EndingColumnNumber=24&amp;EndingLineNumber=6&amp;StartingColumnNumber=9&amp;StartingLineNumber=6&amp;Timestamp=471293286.469901"
11+
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=329&amp;EndingColumnNumber=24&amp;EndingLineNumber=7&amp;StartingColumnNumber=9&amp;StartingLineNumber=7&amp;Timestamp=471298613.499876"
1212
selectedRepresentationIndex = "0"
1313
shouldTrackSuperviewWidth = "NO">
1414
</LoggerValueHistoryTimelineItem>

Source/Blog.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public final class Blog: NSObject, ResponseObjectSerializable, ResponseCollectio
6464
self.trackCountNum = NSNumber(integer: trackCount)
6565
self.imageURL = imageURL
6666
self.imageURLSmall = imageURLSmall
67-
self.featured = representation.objectForKey("ts_featured") != nil
68-
self.following = representation.objectForKey("ts_loved_me") != nil
67+
self.featured = representation.objectForKey("ts_featured") is Int
68+
self.following = representation.objectForKey("ts_loved_me") is Int
6969

7070
super.init()
7171
}

0 commit comments

Comments
 (0)