我有我的应用程序收到应用程序的场景:openURL:来自扩展程序的sourceApplication调用,我想在我的tabBar中打开一个选项卡,一旦完全加载,然后sendNext就会发出一个信号,tabBar一旦加载就会监听
所以事件的顺序如下:
侦听openURLSubject的RemindersViewController将执行一些操作,因为它现在已加载并发出信号。
class AppDelegate:UIResponder,UIApplicationDelegate {
let openURLSubject = RACSubject()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
RemindersLoadedSignal.subscribeNextAs({ (loaded:NSBool) -> () in
println("This subscription works for some reason")
})
return true
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
myTabBar.selectTabWithClass(RemindersViewController.self)
//SendNext to openURLSubject once the tab is loaded
RemindersLoadedSignal.subscribeNextAs({ (loaded:NSBool) -> () in
println("This subscription Never gets called")
self.openURLSubject.sendNext(reminderURLRequest)
})
return true
}
}
让RemindersLoadedSignal = RACSubject()
class RemindersViewController:UIViewController,UITableViewDelegate,UITableViewDataSource {
override func viewDidLoad(){
super.viewDidLoad()
bindViewModel()
}
func bindViewModel(){
sharedAppDelegate().openURLSubject.subscribeNextAs { (request:OpenURLRequest) -> () in
println("got url request")
}
RemindersLoadedSignal.sendNext(NSBoolTrue)
}
}
我不明白didFinishLaunchingWithOptions中的订阅是如何工作的以及应用程序中的订阅:openURL:... doesnt。
答案 0 :(得分:0)
我最后使用doNext加载视图并使用RemindersLoadedSignal压缩信号。
如果您发现任何潜在问题,请告诉我。
由于
.doNext { (_:AnyObject!) -> Void in
if let myTabBar = self.window?.rootViewController as? UITabBarController {
myTabBar.selectTabWithClass(RemindersViewController.self)
}
}
.zipWith(RemindersLoadedSignal)