0
A
回答
1
您将需要从接收推送通知的对象中坚持CLASSB参考:
// The header file of the class that receives the notification
@class classB;
@interface MyNotifiedClass : NSObject
{
classB *_classB;
}
@property (retain, nonatomic, readwrite) classB *classB;
// The implementation file of the class that receives the notification
@implementation MyNotifiedClass
....
@synthesize classB = _classB;
- (void)theMethodThatReceivesTheNotification:(whatever)
{
[_classB doSomethingNowPlease];
}
你显然必须设置在这个类的classB
实例之前,将工作:
// Someplace outside both classes (assuming _classB points to an instance of classB
// and _myNotifiedClass points to an instance of MyNotifiedClass)
[_myNotifiedClass setClassB:_classB];
0
有没有办法调用一个类的实例方法没有实例化它。您的解决方案是调用类方法或classB
可能有单例初始化程序。
相关问题
- 1. 在接收推送通知时在后台运行javascript函数?
- 2. 在接收推送通知时在背景中调用音频
- 3. WP8.1接收推送通知
- 4. 如何在应用程序关闭时接收推送通知?
- 5. 如何在接收推送通知时进行服务器调用?
- 6. 在应用程序关闭时收到推送通知后调用函数?
- 7. 如何在iPhone接收到推送通知时
- 8. 使用Node.js接收推送通知webToolkit
- 9. 用声音接收推送通知
- 10. 推送通知不在iphone上接收
- 11. 在接收推送通知时启动活动(如Skype/WhatsApp调用)
- 12. 如何在angularJs web中使用FCM接收推送通知?
- 13. 如何在没有AppDelegate的iOS中收到推送通知时收到通知?
- 14. Worklight应用程序在接收推送通知时崩溃
- 15. 如何在应用未启动时接收推送通知时显示alertview?
- 16. AdHoc构建不接收推送通知
- 17. 接收推送通知从Sinch,Swift 3
- 18. 推送通知iOS 8未接收
- 19. 显示接收的推送通知
- 20. Iphone无法接收推送通知
- 21. 接收推送通知不一致
- 22. Android parse.com无法接收推送通知
- 23. Xtify - 未接收推送通知 - Android
- 24. 如何区分在应用中收到的推送通知和从应用外接触到的推送通知?
- 25. Android如何使用drupal服务器接收推送通知
- 26. 如何接收其他应用的推送通知?
- 27. 如何在前台iOS Swift 3.0中接收推送通知?
- 28. 如何通过Indy接收推送通知?
- 29. 未收到推送通知
- 30. 未收到推送通知
我不知道你是否清楚你的Object Livecycles。如果ClassB是一个sigleton类,那么只需使用它作为一个访问器。如果你只是想调用ClassB中的方法,如果ClassB的任何对象存在,则使用NSNotification机制,在创建ClassB时将其设置并在dealloc上销毁它。为了减少这一点:ClassB的生命周期是解决你的问题的重要部分;) – monkeydom