UIViewController屏幕上的当前需要通过设置徽标视图来响应来自APN的推送通知.但我怎么能得到UIViewControllerin方法application:didReceiveRemoteNotification:AppDelegate.m?
我尝试使用self.window.rootViewController获取当前显示UIViewController,它可能是一种UINavigationViewController或其他类型的视图控制器.我发现可以用来获取屏幕上的visibleViewController属性.但如果它不是,我该怎么办?UINavigationViewControllerUIViewControllerUINavigationViewController
任何帮助表示赞赏!相关代码如下.
AppDelegate.m
...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//I would like to find out which view controller is on the screen here.
UIViewController *vc = [(UINavigationViewController *)self.window.rootViewController visibleViewController];
[vc performSelector:@selector(handleThePushNotification:) withObject:userInfo];
}
...
Run Code Online (Sandbox Code Playgroud)
ViewControllerA.m
- (void)handleThePushNotification:(NSDictionary *)userInfo{
//set some badge view here
}
Run Code Online (Sandbox Code Playgroud) 我正在编写一个iOS应用程序,我需要使用内置Xcode调试器的帮助.假设我有一个名为的对象HomeViewController有三个属性
@property (nonatomic) BOOL finished;
@property (nonatomic, strong) NSArray *myArray;
@property (nonatomic, strong) NSString *myName;
@synthesize finished = _finished, myArray = _myArray, myName = _myName;
Run Code Online (Sandbox Code Playgroud)
假设我在这个班级有一个断点.我如何查看这些属性的内容?我试过的东西,如po myName,print myName和print [self myName],但我无法弄清楚如何做到这一点.我已经尝试过使用LLDB,但是我一直遇到这个人遇到的错误(lldb无法打印变量值,"错误:引用'id'是不明确的").对这个问题的接受答案是,LLDB被破坏了,我应该只使用GDB; 但是,我拒绝接受那些根本被打破的东西.
不过,我也尝试过使用GDB和上面类似的命令; 但是,我无法让GDB工作.请帮忙