Chapter 23 - Challenges (errata)

I’ve seen that if you wait for the next pull for new tweets (after timeDelay) Tweetie crashes with (Error.duplicateItem(item: item) in Diff.swift from Differentiator.

Could work around the problem by changing the code in TwitterAPI.swift to

  static func timeline(of username: String) -> (AccessToken, TimelineCursor) -> Observable<[JSONObject]> {
    return { account, cursor in
        var parameters = ["screen_name": username, "contributor_details": "false", "count": "100", "include_rts": "true"]
        if cursor != .none {
            parameters.merge(["max_id": "\(cursor.maxId)", "since_id": "\(cursor.sinceId)"]) { (_, new) in new }
        return request(account, address: TwitterAPI.Address.timeline, parameters: parameters)

basically using the cursor. Though I’m not sure wether Diff should be able to handle the case of comparing the the same sets of items.


@rabe Thank you for sharing the solution - much appreciated!