Use reloaddata

This commit is contained in:
kevinzhow
2015-10-27 22:45:45 +08:00
parent 3d888f30a3
commit 110e4e9998
@@ -198,26 +198,27 @@ class FeedsViewController: UIViewController {
if let strongSelf = self {
let oldFeedSet = Set(strongSelf.feeds)
let newFeedSet = Set(feeds)
// let oldFeedSet = Set(strongSelf.feeds)
// let newFeedSet = Set(feeds)
let unionFeedSet = oldFeedSet.union(newFeedSet)
let allNewFeedSet = newFeedSet.subtract(oldFeedSet)
// let unionFeedSet = oldFeedSet.union(newFeedSet)
// let allNewFeedSet = newFeedSet.subtract(oldFeedSet)
let allFeeds = Array(unionFeedSet).sort({ $0.createdUnixTime > $1.createdUnixTime })
let newIndexPaths = allNewFeedSet.map({ allFeeds.indexOf($0) }).flatMap({ $0 }).map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) })
// let allFeeds = Array(unionFeedSet)
//
// let newIndexPaths = allNewFeedSet.map({ allFeeds.indexOf($0) }).flatMap({ $0 }).map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) })
dispatch_async(dispatch_get_main_queue()) {
strongSelf.feeds = allFeeds
if newIndexPaths.count == allNewFeedSet.count {
strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(newIndexPaths)
} else {
strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(nil)
}
strongSelf.feeds = feeds
strongSelf.feedsTableView.reloadData()
// if newIndexPaths.count == allNewFeedSet.count {
// strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(newIndexPaths)
//
// } else {
// strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(nil)
// }
}
}
})