An example of MVVM-C + UIKit + Combine + Realm show/insert Garment items.
- Using Swift + MVVM-C + UIKit + Combine + POP + Realm
- Show Garment items sorted by alphabet and create date.
- Load/save items into Realm Database.
- Make UI with 2 ways storyboard and programmatically.
- Light & dark mode compatible.
- Limit using third-party libraries.
- Unit test
- iOS 13.0+
- Xcode 12.2
Using MVVM-C pattern gives us some benefits like code reuse, ease of testing, bindings make UI updates easier to handle, ease of maintainability.
And splitting off protocols (DataSource and Delegate) into separate objects we can re-use those objects in other view controllers, or use different objects in the same view controller to get different behavior at runtime.
func test_add_new_item_count_1() {
//Given
let count = 1
let item = Garment(name: "Hat", createdDate: Date())
//When
try! repository().insert(item: item)
let items = repository().fetchAll()
//Then
XCTAssertEqual(count, items.count)
}
To run the project, clone the repo, and run pod install
from the project directory first.
- Make UI with SwiftUI
Tommy Doan, [email protected] or [email protected]