Skip to content

Commit

Permalink
Release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
djorkaeffalexandre committed Nov 3, 2020
2 parents 3d18a98 + eb4a912 commit e8edacf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Chuck Norris Facts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1266,12 +1266,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = PHM6B5Y356;
INFOPLIST_FILE = "Chuck Norris Facts/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "net.djorkaeff.Chuck-Norris-Facts";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1285,12 +1287,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = PHM6B5Y356;
INFOPLIST_FILE = "Chuck Norris Facts/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "net.djorkaeff.Chuck-Norris-Facts";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Lottie

final class FactsListViewController: UIViewController {

var viewModel: FactsListViewModel!
var viewModel: FactsListViewModel?

private let disposeBag = DisposeBag()

Expand Down Expand Up @@ -104,6 +104,8 @@ final class FactsListViewController: UIViewController {
}

private func setupBindings() {
guard let viewModel = viewModel else { return }

rx.viewDidAppear
.bind(to: viewModel.inputs.viewDidAppear)
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import RxDataSources

final class SearchFactsViewController: UIViewController {

var viewModel: SearchFactsViewModel!
var viewModel: SearchFactsViewModel?

let disposeBag = DisposeBag()

Expand Down Expand Up @@ -109,6 +109,8 @@ final class SearchFactsViewController: UIViewController {
}

private func setupBindings() {
guard let viewModel = viewModel else { return }

rx.viewWillAppear
.bind(to: viewModel.inputs.viewWillAppear)
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class SuggestionsCell: UITableViewCell {
}
)

var viewModel: SuggestionsViewModel! {
var viewModel: SuggestionsViewModel? {
didSet {
self.setupBindings()
}
Expand Down Expand Up @@ -71,6 +71,8 @@ final class SuggestionsCell: UITableViewCell {
}

private func setupBindings() {
guard let viewModel = viewModel else { return }

collectionView.rx
.setDelegate(self)
.disposed(by: disposeBag)
Expand Down
14 changes: 11 additions & 3 deletions Chuck Norris Facts/Core/Data/Storage/FactsStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,40 @@ protocol FactsStorageType {
}

final class FactsStorage: FactsStorageType {
private let realm: Realm!
private let realm: Realm?

init(realm: Realm? = nil) {
self.realm = realm ?? (try? Realm())
}

func storeCategories(_ categories: [FactCategory]) {
guard let realm = realm else { return }

try? realm.write {
let entities = categories.map(FactCategoryEntity.init)
self.realm.add(entities, update: .modified)
realm.add(entities, update: .modified)
}
}

func retrieveCategories() -> Observable<[FactCategory]> {
guard let realm = realm else { return .never() }

let entities = realm.objects(FactCategoryEntity.self)
return Observable.collection(from: entities).map { $0.map { $0.item } }
}

func storeSearch(searchTerm: String) {
guard let realm = realm else { return }

try? realm.write {
let entity = SearchEntity(searchTerm: searchTerm)
self.realm.add(entity, update: .modified)
realm.add(entity, update: .modified)
}
}

func retrieveSearches() -> Observable<[String]> {
guard let realm = realm else { return .never() }

let entities = realm.objects(SearchEntity.self).sorted(byKeyPath: "updatedAt", ascending: false)
return Observable.collection(from: entities).map { $0.map { $0.searchTerm } }
}
Expand Down
4 changes: 2 additions & 2 deletions Chuck Norris Facts/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
Expand Down

0 comments on commit e8edacf

Please sign in to comment.