Fix esamples

This commit is contained in:
Pedro Piñera Buendía 2016-09-01 00:15:23 +02:00
parent 41bdb52e7e
commit b317c27612
36 changed files with 3874 additions and 3101 deletions

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "23EA8C971D6E1550008333A4"
BuildableName = "Tests.xctest"
BlueprintName = "Tests"
BuildableName = "iOS.xctest"
BlueprintName = "iOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</TestableReference>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D3391D77894000BF8E32"
BuildableName = "macOS.xctest"
BlueprintName = "macOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D3391D77894000BF8E32"
BuildableName = "macOS.xctest"
BlueprintName = "macOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D3391D77894000BF8E32"
BuildableName = "macOS.xctest"
BlueprintName = "macOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D3391D77894000BF8E32"
BuildableName = "macOS.xctest"
BlueprintName = "macOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D32D1D77893500BF8E32"
BuildableName = "tvOS.xctest"
BlueprintName = "tvOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D32D1D77893500BF8E32"
BuildableName = "tvOS.xctest"
BlueprintName = "tvOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D32D1D77893500BF8E32"
BuildableName = "tvOS.xctest"
BlueprintName = "tvOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D32D1D77893500BF8E32"
BuildableName = "tvOS.xctest"
BlueprintName = "tvOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2E01D77889200BF8E32"
BuildableName = "watchOS.app"
BlueprintName = "watchOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "23C453141D7789A900483DB4"
BuildableName = "Examples.app"
BlueprintName = "Examples"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2EC1D77889200BF8E32"
BuildableName = "watchOS Extension.appex"
BlueprintName = "watchOS Extension"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2E01D77889200BF8E32"
BuildableName = "watchOS.app"
BlueprintName = "watchOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/Examples">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2E01D77889200BF8E32"
BuildableName = "watchOS.app"
BlueprintName = "watchOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2E01D77889200BF8E32"
BuildableName = "watchOS.app"
BlueprintName = "watchOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/Examples">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2E01D77889200BF8E32"
BuildableName = "watchOS.app"
BlueprintName = "watchOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2393D2E01D77889200BF8E32"
BuildableName = "watchOS.app"
BlueprintName = "watchOS"
ReferencedContainer = "container:Examples.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -56,7 +56,7 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
// MARK: - UITableViewDataSource / UITableViewDelegate
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
return 2
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
@ -66,10 +66,6 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
cell.textLabel?.text = "CoreData Basic"
case 1:
cell.textLabel?.text = "Realm Basic"
case 2:
cell.textLabel?.text = "CoreData Observable"
case 3:
cell.textLabel?.text = "Realm Observable"
default:
cell.textLabel?.text = ""
}
@ -84,10 +80,6 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
self.navigationController?.pushViewController(CoreDataBasicView(), animated: true)
case 1:
self.navigationController?.pushViewController(RealmBasicView(), animated: true)
case 2:
self.navigationController?.pushViewController(CoreDataObservableView(), animated: true)
case 3:
self.navigationController?.pushViewController(RealmObservableView(), animated: true)
default:
break
}

View File

@ -3,13 +3,29 @@ use_frameworks!
target 'Examples' do
pod 'SnapKit'
pod 'SugarRecord', :path => "../"
pod 'SugarRecord/CoreData', :path => "../"
pod 'SugarRecord/CoreData+iCloud', :path => "../"
pod 'SugarRecord/Realm', :path => "../"
end
target 'Tests' do
target 'iOS' do
pod 'SugarRecord', :path => "../"
pod 'SugarRecord/CoreData', :path => "../"
pod 'SugarRecord/CoreData+iCloud', :path => "../"
pod 'SugarRecord/Realm', :path => "../"
pod "Quick"
pod "Nimble"
end
target 'macOS' do
pod 'SugarRecord', :path => "../"
pod 'SugarRecord/CoreData', :path => "../"
pod 'SugarRecord/CoreData+iCloud', :path => "../"
pod 'SugarRecord/Realm', :path => "../"
end
target 'tvOS' do
# pod 'SugarRecord', :path => "../"
# pod 'SugarRecord/CoreData', :path => "../"
# pod 'SugarRecord/Realm', :path => "../"
end

View File

@ -42,6 +42,6 @@ SPEC CHECKSUMS:
SnapKit: 0dd2fd157330f1ea11fd84da13e6be8a7a22bae0
SugarRecord: 4911b37399933cfaeb90f248ec280858caf91e3e
PODFILE CHECKSUM: a196697021ce9a77aff6b9a4fd98d46107c43c06
PODFILE CHECKSUM: a1045c82a960fbaad95f018ee48d867cd80268f0
COCOAPODS: 1.0.1

View File

@ -42,6 +42,6 @@ SPEC CHECKSUMS:
SnapKit: 0dd2fd157330f1ea11fd84da13e6be8a7a22bae0
SugarRecord: 4911b37399933cfaeb90f248ec280858caf91e3e
PODFILE CHECKSUM: a196697021ce9a77aff6b9a4fd98d46107c43c06
PODFILE CHECKSUM: a1045c82a960fbaad95f018ee48d867cd80268f0
COCOAPODS: 1.0.1

File diff suppressed because it is too large Load Diff

View File

@ -84,16 +84,16 @@ strip_invalid_archs() {
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "$BUILT_PRODUCTS_DIR/Realm-iOS9.2/Realm.framework"
install_framework "$BUILT_PRODUCTS_DIR/RealmSwift-iOS9.2/RealmSwift.framework"
install_framework "$BUILT_PRODUCTS_DIR/Result-iOS9.2/Result.framework"
install_framework "$BUILT_PRODUCTS_DIR/Realm-iOS/Realm.framework"
install_framework "$BUILT_PRODUCTS_DIR/RealmSwift-iOS/RealmSwift.framework"
install_framework "$BUILT_PRODUCTS_DIR/Result-iOS/Result.framework"
install_framework "$BUILT_PRODUCTS_DIR/SnapKit/SnapKit.framework"
install_framework "$BUILT_PRODUCTS_DIR/SugarRecord-iOS9.2/SugarRecord.framework"
install_framework "$BUILT_PRODUCTS_DIR/SugarRecord-iOS/SugarRecord.framework"
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "$BUILT_PRODUCTS_DIR/Realm-iOS9.2/Realm.framework"
install_framework "$BUILT_PRODUCTS_DIR/RealmSwift-iOS9.2/RealmSwift.framework"
install_framework "$BUILT_PRODUCTS_DIR/Result-iOS9.2/Result.framework"
install_framework "$BUILT_PRODUCTS_DIR/Realm-iOS/Realm.framework"
install_framework "$BUILT_PRODUCTS_DIR/RealmSwift-iOS/RealmSwift.framework"
install_framework "$BUILT_PRODUCTS_DIR/Result-iOS/Result.framework"
install_framework "$BUILT_PRODUCTS_DIR/SnapKit/SnapKit.framework"
install_framework "$BUILT_PRODUCTS_DIR/SugarRecord-iOS9.2/SugarRecord.framework"
install_framework "$BUILT_PRODUCTS_DIR/SugarRecord-iOS/SugarRecord.framework"
fi

View File

@ -1,8 +1,8 @@
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS9.2" "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS9.2" "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS9.2" "$PODS_CONFIGURATION_BUILD_DIR/SnapKit" "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS9.2"
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS" "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS" "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS" "$PODS_CONFIGURATION_BUILD_DIR/SnapKit" "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS9.2/Realm.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS9.2/RealmSwift.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS9.2/Result.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SnapKit/SnapKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS9.2/SugarRecord.framework/Headers"
OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS/Realm.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS/RealmSwift.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS/Result.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SnapKit/SnapKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS/SugarRecord.framework/Headers"
OTHER_LDFLAGS = $(inherited) -ObjC -framework "Realm" -framework "RealmSwift" -framework "Result" -framework "SnapKit" -framework "SugarRecord"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_BUILD_DIR = $BUILD_DIR

View File

@ -1,8 +1,8 @@
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS9.2" "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS9.2" "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS9.2" "$PODS_CONFIGURATION_BUILD_DIR/SnapKit" "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS9.2"
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS" "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS" "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS" "$PODS_CONFIGURATION_BUILD_DIR/SnapKit" "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS9.2/Realm.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS9.2/RealmSwift.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS9.2/Result.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SnapKit/SnapKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS9.2/SugarRecord.framework/Headers"
OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Realm-iOS/Realm.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift-iOS/RealmSwift.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Result-iOS/Result.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SnapKit/SnapKit.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/SugarRecord-iOS/SugarRecord.framework/Headers"
OTHER_LDFLAGS = $(inherited) -ObjC -framework "Realm" -framework "RealmSwift" -framework "Result" -framework "SnapKit" -framework "SugarRecord"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_BUILD_DIR = $BUILD_DIR

View File

@ -1,142 +0,0 @@
import Foundation
import UIKit
import SugarRecord
import CoreData
import RxSwift
class CoreDataObservableView: UIViewController, UITableViewDelegate, UITableViewDataSource {
// MARK: - Attributes
lazy var db: CoreDataDefaultStorage = {
let store = CoreData.Store.Named("cd_basic")
let bundle = NSBundle(forClass: CoreDataBasicView.classForCoder())
let model = CoreData.ObjectModel.Merged([bundle])
let defaultStorage = try! CoreDataDefaultStorage(store: store, model: model)
return defaultStorage
}()
lazy var tableView: UITableView = {
let _tableView = UITableView(frame: CGRectZero, style: UITableViewStyle.Plain)
_tableView.translatesAutoresizingMaskIntoConstraints = false
_tableView.delegate = self
_tableView.dataSource = self
_tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "default-cell")
return _tableView
}()
var disposeBag: DisposeBag = DisposeBag()
var entities: [CoreDataBasicEntity] = [] {
didSet {
self.tableView.reloadData()
}
}
// MARK: - Init
init() {
super.init(nibName: nil, bundle: nil)
self.title = "CoreData Observable"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
deinit {
print("🚀🚀🚀 Deallocating \(self) 🚀🚀🚀")
}
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setup()
}
// MARK: - Private
private func setup() {
setupView()
setupNavigationItem()
setupTableView()
setupObservable()
}
private func setupView() {
self.view.backgroundColor = UIColor.whiteColor()
}
private func setupNavigationItem() {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: #selector(CoreDataBasicView.userDidSelectAdd(_:)))
}
private func setupTableView() {
self.view.addSubview(tableView)
self.tableView.snp_makeConstraints { (make) -> Void in
make.edges.equalTo(self.view)
}
}
private func setupObservable() {
db.observable(Request<BasicObject>().sortedWith("date", ascending: true))
.rx_observe()
.subscribeNext { [weak self] (change) in
switch change {
case .Initial(let entities):
self?.entities = entities.map(CoreDataBasicEntity.init)
break
case .Update(let deletions, let insertions, let modifications):
modifications.forEach { [weak self] in self?.entities[$0.0] = CoreDataBasicEntity(object: $0.1) }
insertions.forEach { [weak self] in self?.entities.insert(CoreDataBasicEntity(object: $0.1), atIndex: $0.0) }
deletions.forEach({ [weak self] in self?.entities.removeAtIndex($0) })
break
default:
break
}
}
.addDisposableTo(self.disposeBag)
}
// MARK: - UITableViewDataSource / UITableViewDelegate
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.entities.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("default-cell")!
cell.textLabel?.text = "\(entities[indexPath.row].name) - \(entities[indexPath.row].dateString)"
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
let name = entities[indexPath.row].name
try! db.operation({ (context, save) -> Void in
guard let obj = try! context.request(BasicObject.self).filteredWith("name", equalTo: name).fetch().first else { return }
_ = try? context.remove(obj)
save()
})
}
}
// MARK: - Actions
func userDidSelectAdd(sender: AnyObject!) {
try! db.operation { (context, save) -> Void in
let _object: BasicObject = try! context.new()
_object.date = NSDate()
_object.name = randomStringWithLength(10) as String
try! context.insert(_object)
save()
}
}
}

View File

@ -1,141 +0,0 @@
import Foundation
import UIKit
import SugarRecord
import RealmSwift
import RxSwift
class RealmObservableView: UIViewController, UITableViewDelegate, UITableViewDataSource {
// MARK: - Attributes
lazy var db: RealmDefaultStorage = {
var configuration = Realm.Configuration()
configuration.fileURL = NSURL(fileURLWithPath: databasePath("realm-basic"))
let _storage = RealmDefaultStorage(configuration: configuration)
return _storage
}()
lazy var tableView: UITableView = {
let _tableView = UITableView(frame: CGRectZero, style: UITableViewStyle.Plain)
_tableView.translatesAutoresizingMaskIntoConstraints = false
_tableView.delegate = self
_tableView.dataSource = self
_tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "default-cell")
return _tableView
}()
var entities: [RealmBasicEntity] = [] {
didSet {
self.tableView.reloadData()
}
}
var disposeBag: DisposeBag = DisposeBag()
// MARK: - Init
init() {
super.init(nibName: nil, bundle: nil)
self.title = "Realm Observable View"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
deinit {
print("🚀🚀🚀 Deallocating \(self) 🚀🚀🚀")
}
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setup()
}
// MARK: - Private
private func setup() {
setupView()
setupNavigationItem()
setupTableView()
setupObservable()
}
private func setupView() {
self.view.backgroundColor = UIColor.whiteColor()
}
private func setupNavigationItem() {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: #selector(RealmBasicView.userDidSelectAdd(_:)))
}
private func setupTableView() {
self.view.addSubview(tableView)
self.tableView.snp_makeConstraints { (make) -> Void in
make.edges.equalTo(self.view)
}
}
private func setupObservable() {
db.observable(Request<RealmBasicObject>().sortedWith("date", ascending: true))
.rx_observe()
.subscribeNext { [weak self] (change) in
switch change {
case .Initial(let entities):
self?.entities = entities.map(RealmBasicEntity.init)
break
case .Update(let deletions, let insertions, let modifications):
modifications.forEach { [weak self] in self?.entities[$0.0] = RealmBasicEntity(object: $0.1) }
insertions.forEach { [weak self] in self?.entities.insert(RealmBasicEntity(object: $0.1), atIndex: $0.0) }
deletions.forEach({ [weak self] in self?.entities.removeAtIndex($0) })
break
default:
break
}
}
.addDisposableTo(self.disposeBag)
}
// MARK: - UITableViewDataSource / UITableViewDelegate
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.entities.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("default-cell")!
cell.textLabel?.text = "\(entities[indexPath.row].name) - \(entities[indexPath.row].dateString)"
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
let name = entities[indexPath.row].name
try! db.operation({ (context, save) -> Void in
guard let obj = try! context.request(RealmBasicObject.self).filteredWith("name", equalTo: name).fetch().first else { return }
_ = try? context.remove(obj)
save()
})
}
}
// MARK: - Actions
func userDidSelectAdd(sender: AnyObject!) {
try! db.operation { (context, save) -> Void in
let _object: RealmBasicObject = try! context.new()
_object.date = NSDate()
_object.name = randomStringWithLength(10) as String
try! context.insert(_object)
save()
}
}
}

24
Examples/macOS/Info.plist Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,14 +1,14 @@
//
// Tests.swift
// Tests
// macOS.swift
// macOS
//
// Created by Pedro Pinera Buendia on 24/08/16.
// Created by Pedro Pinera Buendia on 31/08/16.
// Copyright © 2016 SwiftReactive. All rights reserved.
//
import XCTest
class Tests: XCTestCase {
class macOS: XCTestCase {
override func setUp() {
super.setUp()

24
Examples/tvOS/Info.plist Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

35
Examples/tvOS/tvOS.swift Normal file
View File

@ -0,0 +1,35 @@
//
// tvOS.swift
// tvOS
//
// Created by Pedro Pinera Buendia on 31/08/16.
// Copyright © 2016 SwiftReactive. All rights reserved.
//
import XCTest
class tvOS: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}
}

View File

@ -1,5 +1,4 @@
source 'https://rubygems.org'
gem "jazzy"
gem "fastlane"
gem "cocoapods"

View File

@ -9,9 +9,9 @@ GEM
tzinfo (~> 1.1)
addressable (2.4.0)
babosa (1.0.2)
cert (1.4.1)
fastlane_core (>= 0.29.1, < 1.0.0)
spaceship (>= 0.22.0, < 1.0.0)
cert (1.4.2)
fastlane_core (>= 0.50.3, < 1.0.0)
spaceship (>= 0.32.0, < 1.0.0)
claide (1.0.0)
cocoapods (1.0.1)
activesupport (>= 4.0.2)
@ -34,8 +34,8 @@ GEM
activesupport (>= 4.0.2)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.0)
cocoapods-downloader (1.1.0)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
@ -72,29 +72,29 @@ GEM
faraday (>= 0.7.4, < 0.10)
fastimage (1.6.8)
addressable (~> 2.3, >= 2.3.5)
fastlane (1.101.0)
fastlane (1.102.0)
activesupport (< 5)
addressable (~> 2.3)
bundler (~> 1.12)
cert (>= 1.4.1, < 2.0.0)
credentials_manager (>= 0.16.0, < 1.0.0)
deliver (>= 1.13.2, < 2.0.0)
deliver (>= 1.13.3, < 2.0.0)
fastlane_core (>= 0.50.2, < 1.0.0)
frameit (>= 2.7.0, < 3.0.0)
gym (>= 1.7.0, < 2.0.0)
krausefx-shenzhen (>= 0.14.10)
match (>= 0.6.2, < 1.0.0)
match (>= 0.6.3, < 1.0.0)
multipart-post (~> 2.0.0)
pem (>= 1.3.2, < 2.0.0)
pilot (>= 1.10.0, < 2.0.0)
plist (~> 3.1.0)
produce (>= 1.2.0, < 2.0.0)
scan (>= 0.11.3, < 2.0.0)
screengrab (>= 0.3.2, < 1.0.0)
sigh (>= 1.9.0, < 2.0.0)
screengrab (>= 0.5.0, < 1.0.0)
sigh (>= 1.10.0, < 2.0.0)
slack-notifier (~> 1.3)
snapshot (>= 1.13.1, < 2.0.0)
spaceship (>= 0.31.2, < 1.0.0)
snapshot (>= 1.14.0, < 2.0.0)
spaceship (>= 0.32.0, < 1.0.0)
supply (>= 0.7.0, < 1.0.0)
terminal-notifier (~> 1.6.2)
terminal-table (~> 1.4.5)
@ -123,7 +123,7 @@ GEM
mini_magick (~> 4.5.1)
fuzzy_match (2.0.4)
gh_inspector (1.0.2)
google-api-client (0.9.12)
google-api-client (0.9.13)
addressable (~> 2.3)
googleauth (~> 0.5)
httpclient (~> 2.7)
@ -132,7 +132,6 @@ GEM
mime-types (>= 1.6)
representable (~> 2.3.0)
retriable (~> 2.0)
thor (~> 0.19)
googleauth (0.5.1)
faraday (~> 0.9)
jwt (~> 1.4)
@ -141,8 +140,8 @@ GEM
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
gym (1.7.0)
fastlane_core (>= 0.43.3, < 1.0.0)
gym (1.8.0)
fastlane_core (>= 0.50.0, < 1.0.0)
plist
rubyzip (>= 1.1.7)
terminal-table
@ -150,18 +149,9 @@ GEM
highline (1.7.8)
http-cookie (1.0.2)
domain_name (~> 0.5)
httpclient (2.8.2.2)
httpclient (2.8.2.3)
hurley (0.2)
i18n (0.7.0)
jazzy (0.7.0)
cocoapods (~> 1.0)
mustache (~> 0.99)
open4
redcarpet (~> 3.2)
rouge (~> 1.5)
sass (~> 3.4)
sqlite3 (~> 1.3)
xcinvoke (~> 0.2.1)
json (1.8.3)
jwt (1.5.4)
krausefx-shenzhen (0.14.10)
@ -176,18 +166,17 @@ GEM
rubyzip (~> 1.1)
security (~> 0.1.3)
terminal-table (~> 1.4.5)
liferaft (0.0.4)
little-plugger (1.1.4)
logging (2.1.0)
little-plugger (~> 1.1)
multi_json (~> 1.10)
match (0.6.2)
cert (>= 1.2.8, < 2.0.0)
credentials_manager (>= 0.13.0, < 1.0.0)
fastlane_core (>= 0.39.0, < 1.0.0)
match (0.6.3)
cert (>= 1.4.1, < 2.0.0)
credentials_manager (>= 0.16.0, < 1.0.0)
fastlane_core (>= 0.50.3, < 1.0.0)
security
sigh (>= 1.2.2, < 2.0.0)
spaceship (>= 0.24.0, < 1.0.0)
sigh (>= 1.9.0, < 2.0.0)
spaceship (>= 0.31.10, < 1.0.0)
memoist (0.15.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
@ -198,13 +187,11 @@ GEM
multi_json (1.12.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
mustache (0.99.8)
nap (1.1.0)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (3.2.0)
netrc (0.7.8)
open4 (1.3.4)
os (0.9.6)
pem (1.3.2)
fastlane_core (>= 0.43.1, < 1.0.0)
@ -218,23 +205,21 @@ GEM
produce (1.2.0)
fastlane_core (>= 0.30.0, < 1.0.0)
spaceship (>= 0.31.1, < 1.0.0)
redcarpet (3.3.4)
representable (2.3.0)
uber (~> 0.0.7)
retriable (2.1.0)
rouge (1.11.1)
rubyzip (1.1.7)
sass (3.4.22)
scan (0.11.3)
fastlane_core (>= 0.50.0, < 1.0.0)
slack-notifier (~> 1.3)
terminal-table
xcpretty (>= 0.2.1)
xcpretty-travis-formatter (>= 0.0.3)
screengrab (0.5.0)
fastlane_core (>= 0.50.0, < 1.0.0)
screengrab (0.5.1)
fastlane_core (>= 0.50.3, < 1.0.0)
security (0.1.3)
sigh (1.9.0)
sigh (1.10.1)
fastlane_core (>= 0.36.1, < 1.0.0)
plist (~> 3.1)
spaceship (>= 0.29.1, < 1.0.0)
@ -244,12 +229,12 @@ GEM
jwt (~> 1.5)
multi_json (~> 1.10)
slack-notifier (1.5.1)
snapshot (1.13.1)
snapshot (1.14.0)
fastimage (~> 1.6.3)
fastlane_core (>= 0.50.0, < 1.0.0)
fastlane_core (>= 0.50.3, < 1.0.0)
plist (~> 3.1.0)
xcpretty (>= 0.2.1)
spaceship (0.31.8)
spaceship (0.32.0)
colored
credentials_manager (>= 0.16.0)
faraday (~> 0.9)
@ -258,14 +243,12 @@ GEM
fastimage (~> 1.6)
multi_xml (~> 0.5)
plist (~> 3.1)
sqlite3 (1.3.11)
supply (0.7.0)
supply (0.7.1)
credentials_manager (>= 0.15.0)
fastlane_core (>= 0.43.4)
google-api-client (~> 0.9.1)
terminal-notifier (1.6.3)
terminal-table (1.4.5)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
@ -274,8 +257,6 @@ GEM
unf_ext
unf_ext (0.0.7.2)
word_wrap (1.0.0)
xcinvoke (0.2.1)
liferaft (~> 0.0.4)
xcode-install (2.0.2)
claide (>= 0.9.1, < 1.1.0)
spaceship (>= 0.25.1, < 1.0.0)
@ -294,7 +275,6 @@ PLATFORMS
DEPENDENCIES
cocoapods
fastlane
jazzy
BUNDLED WITH
1.12.5

View File

@ -210,15 +210,6 @@ class Presenter {
**:warning: `RequestObservable` is not available for CoreData + OSX**
### Example project
There's an example project available in `Example` folder.
1. Open the folder and execute `pod install`
2. Open the project using `SugarRecordExamples.xcworkspace`
Feel free to propose new examples using SugarRecord :heart:
## Resources
- [Quick](https://github.com/quick/quick)
- [Nimble](https://github.com/quick/nimble)