spec() { describe("the 'Documentation' directory") { it("has everything you need to get started") { let sections = Directory("Documentation").sections expect(sections).to(contain("Organized Tests with Quick Examples and Example Groups")) expect(sections).to(contain("Installing Quick")) } context("if it doesn't have what you're looking for") { it("needs to be updated") { let you = You(awesome: true) expect{you.submittedAnIssue}.toEventually(beTruthy()) } } } } }
NewsMeta { public let newsId: Int public let title: String public let imageURLs: [NSURL] } { "id": 12345, "title": "Title of the News", "images": ["http://image.url"] }
the value is .None, the function will not be evaluated and this will return .None - If the value is .Some, the function will be applied to the unwrapped value :param: f A transformation function from type T to type U :param: a A value of type Optional<T> :returns: A value of type Optional<U> */ return NewsMeta.create <^> (j <| "id") public func <^><T, U>(f: T -> U, a: T?) -> U?
the value is .None, the function will not be evaluated and this will return .None - If the value is .Some, the function will be applied to the unwrapped value :param: f A transformation function from type T to type U :param: a A value of type Optional<T> :returns: A value of type Optional<U> */ return NewsMeta.create <^> (j <| "id") public func <^><T, U>(f: T -> U, a: T?) -> U? Q: What’s the type of U in this case?
the value is .None, the function will not be evaluated and this will return .None - If the value is .Some, the function will be applied to the unwrapped value :param: f A transformation function from type T to type U :param: a A value of type Optional<T> :returns: A value of type Optional<U> */ return NewsMeta.create <^> (j <| "id") public func <^><T, U>(f: T -> U, a: T?) -> U? A: Partially Applied create function Q: What’s the type of U in this case?
<*> j <|| "images" /** apply an optional function to an optional value - If either the value or the function are .None, the function will not be evaluated and this will return .None - If both the value and the function are .Some, the function will be applied to the unwrapped value :param: f An optional transformation function from type T to type U :param: a A value of type Optional<T> :returns: A value of type Optional<U> */ public func <*><T, U>(f: (T -> U)?, a: T?) -> U? public func <^><T, U>(f: T -> U, a: T?) -> U?
- If the value is .None, the function will not be evaluated and this will return .None - If the value is .Some, the function will be applied to the unwrapped value :param: f A transformation function from type T to type Optional<U> :param: a A value of type Optional<T> :returns: A value of type Optional<U> */ public func >>-<T, U>(a: T?, f: T -> U?) -> U?
News { public let newsId: Int public let title: String public let body: String public let cssURLs: [NSURL] public let imageURL: NSURL public let imageSourceText: String public let shareURL: NSURL }
News { public let newsId: Int public let title: String public let body: String public let cssURLs: [NSURL] public let imageURL: NSURL public let imageSourceText: String public let shareURL: NSURL } public static func decode(j: JSON) -> Decoded<News> { return News.create <^> j <| "id" <*> j <| "title" <*> j <| "body" <*> j <|| "css" <*> j <| "image" <*> j <| "image_source" <*> j <| "share_url" }
Decoded<NSURL> { switch(j) { case let .String(s): return Decoded<NSURL>.fromOptional(NSURL(string: s)) default: return .TypeMismatch("\(j) is not a NSURL.") } } }
Decoded<NSURL> { switch(j) { case let .String(s): return Decoded<NSURL>.fromOptional(NSURL(string: s)) default: return .TypeMismatch("\(j) is not a NSURL.") } } } 20150707
= 0 dynamic public var title: String = "" } public class DailyObject: Object { dynamic public var dateHash: Int = 0 dynamic public var date: NSDate = NSDate() public let news = List<NewsMetaObject>() }