mirror of
https://github.com/zhigang1992/Pick.git
synced 2026-05-23 06:22:51 +08:00
Fix Contact Disallow Crash
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
Pods
|
||||
*.xcuserdatad
|
||||
**/*.xcuserdatad/
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
0440B2B41BA8FC5700923EA3 /* SectionModelType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionModelType.swift; sourceTree = "<group>"; };
|
||||
0440B2C21BA928BD00923EA3 /* presets.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = presets.json; sourceTree = "<group>"; };
|
||||
049EB1551BA7D33B001C8113 /* MainStoryboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainStoryboard.swift; sourceTree = "<group>"; };
|
||||
04F93F241BA434A0004377C8 /* pick.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = pick.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
04F93F241BA434A0004377C8 /* Pick.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pick.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
04F93F271BA434A0004377C8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
04F93F291BA434A0004377C8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
04F93F2C1BA434A1004377C8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
@@ -116,7 +116,7 @@
|
||||
04F93F251BA434A0004377C8 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
04F93F241BA434A0004377C8 /* pick.app */,
|
||||
04F93F241BA434A0004377C8 /* Pick.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -178,7 +178,7 @@
|
||||
);
|
||||
name = pick;
|
||||
productName = pick;
|
||||
productReference = 04F93F241BA434A0004377C8 /* pick.app */;
|
||||
productReference = 04F93F241BA434A0004377C8 /* Pick.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
@@ -416,7 +416,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.hackplan.pick;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PRODUCT_NAME = Pick;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -429,7 +429,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.hackplan.pick;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PRODUCT_NAME = Pick;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "04F93F231BA434A0004377C8"
|
||||
BuildableName = "pick.app"
|
||||
BuildableName = "Pick.app"
|
||||
BlueprintName = "pick"
|
||||
ReferencedContainer = "container:pick.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -33,7 +33,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "04F93F231BA434A0004377C8"
|
||||
BuildableName = "pick.app"
|
||||
BuildableName = "Pick.app"
|
||||
BlueprintName = "pick"
|
||||
ReferencedContainer = "container:pick.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -56,7 +56,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "04F93F231BA434A0004377C8"
|
||||
BuildableName = "pick.app"
|
||||
BuildableName = "Pick.app"
|
||||
BlueprintName = "pick"
|
||||
ReferencedContainer = "container:pick.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -75,7 +75,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "04F93F231BA434A0004377C8"
|
||||
BuildableName = "pick.app"
|
||||
BuildableName = "Pick.app"
|
||||
BlueprintName = "pick"
|
||||
ReferencedContainer = "container:pick.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
||||
@@ -65,7 +65,7 @@ class PresetViewController: UITableViewController {
|
||||
|
||||
contactPreset.prerender = create({ subscribe -> Disposable in
|
||||
APAddressBook().loadContacts({ (contacts, error) -> Void in
|
||||
if error != nil {
|
||||
if contacts == nil {
|
||||
subscribe.on(Event.Error(NSError(domain: "System", code: 403, userInfo: [NSLocalizedDescriptionKey: "Please allow access in Settings.app"])))
|
||||
} else {
|
||||
let candidates = contacts.map({ (contact) -> String in
|
||||
@@ -98,10 +98,14 @@ class PresetViewController: UITableViewController {
|
||||
|
||||
self.tableView
|
||||
.rx_itemSelected
|
||||
.doOn(next:{[unowned self] ip in self.tableView.deselectRowAtIndexPath(ip, animated: true)})
|
||||
.map({[unowned self] ip in return self.dataSource.itemAtIndexPath(ip) })
|
||||
.flatMap({ (preset:Preset) -> Observable<Preset> in
|
||||
return preset.prerender ?? just(preset)
|
||||
return preset.prerender?.doOn(error:{ (error:ErrorType) in
|
||||
UIAlertView(title: "Error", message: (error as NSError).localizedDescription, delegate: nil, cancelButtonTitle: "Okay").show()
|
||||
}).catchErrorJustReturn(preset) ?? just(preset)
|
||||
})
|
||||
.filter({$0.candidate.count > 0})
|
||||
.subscribeNext({[unowned self] (preset:Preset) in
|
||||
preset.saveToUserDefault()
|
||||
self.performSegue(Segue.done)
|
||||
|
||||
@@ -82,12 +82,12 @@ class SettingsViewController: UITableViewController, MFMailComposeViewController
|
||||
}).addDisposableTo(disposeBag)
|
||||
|
||||
self.hint.text = DataHolder.shared.hint
|
||||
[self.hint.rx_text.throttle(1, MainScheduler.sharedInstance), self.disappear.map({[unowned self] _ -> String in return self.hint.text ?? "Hit it"})].asObservable().merge()
|
||||
.subscribeNext({ DataHolder.shared.hint = $0 })
|
||||
self.hint.rx_text.subscribeNext({ DataHolder.shared.hint = $0 })
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
self.dataSource.text = DataHolder.shared.candidates.joinWithSeparator("\n")
|
||||
self.dataSource.rx_text.skip(1).throttle(1, MainScheduler.sharedInstance).map({ (t:String) in
|
||||
[self.dataSource.rx_text.throttle(1, MainScheduler.sharedInstance),
|
||||
self.disappear.map({[unowned self] _ -> String in return self.hint.text ?? ""})].asObservable().merge().distinctUntilChanged().skip(1).map({ (t:String) in
|
||||
return t.componentsSeparatedByString("\n")
|
||||
}).subscribeNext({ data in
|
||||
DataHolder.shared.candidates = data
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user