Skip to content

Instantly share code, notes, and snippets.

View BalestraPatrick's full-sized avatar

Patrick Balestra BalestraPatrick

View GitHub Profile
let dictionary: [String: Any] = [
"color": "blue",
"width": 5.0,
]
func XCTAssertEqual(_ l: [String: Any], _ r: [String: Any]) {
l.keys.forEach { key in
if let left = l[key] as? String, let right = r[key] as? String {
XCTAssertEqual(left, right)
} else if let left = l[key] as? CGFloat, let right = r[key] as? CGFloat {

Keybase proof

I hereby claim:

  • I am BalestraPatrick on github.
  • I am balestrapatrick (https://keybase.io/balestrapatrick) on keybase.
  • I have a public key whose fingerprint is E54C 0A34 CE68 E5D0 3458 859A 2A26 C2FA 0AD1 F7C5

To claim this, I am signing this object:

let viewModel = ViewModel()
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
dataSource.configureCell = { table, indexPath, user in
let cell = table.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let string = "\(user.screenName) is following \(user.followingCount) users and is followed by \(user.followersCount) users."
cell.textLabel?.text = string
cell.textLabel?.numberOfLines = 0
cell.backgroundColor = indexPath.row % 2 == 0 ? UIColor.whiteColor() : UIColor(red: 0, green: 0, blue: 0, alpha: 0.05)
return cell
func getUsers() -> Observable<[SectionModel<String, User>]> {
return Observable.create { (observer) -> Disposable in
let users = [User(followersCount: 1005, followingCount: 495, screenName: "BalestraPatrick"),
User(followersCount: 380, followingCount: 5, screenName: "RxSwiftLang"),
User(followersCount: 36069, followingCount: 0, screenName: "SwiftLang")]
let section = [SectionModel(model: "", items: users)]
observer.onNext(section)
observer.onCompleted()
return AnonymousDisposable{}
}
import UIKit
import RxSwift
class ViewModel {
}
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, User>>()
import Foundation
struct User {
let followersCount: Int
let followingCount: Int
let screenName: String
}
import UIKit
import RxSwift
import RxDataSources
class ViewController: UIViewController, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
import RxSwift
import RxDataSources