我想知道“_lastNotificationReceivedBundleIdentifier”的值,它是类的实例变量。标头从iOS跳板应用程序转储。
@interface SBRemoteNotificationServer : NSObject <APSConnectionDelegate> {
NSMutableDictionary* _bundleIdentifiersToClients;
NSMutableDictionary* _environmentsToConnections;
unsigned _lastPlayedAlertSound;
NSString* _lastNotificationReceivedBundleIdentifier;
}
但以下代码不起作用:
%hook SBRemoteNotificationServer
-(void)noteApplicationFinishedLaunching:(id)launching{
NSLog(@"identifier=%@",_lastNotificationReceivedBundleIdentifier);
%orig;
}
%end
,编译错误是:
error: ‘_lastNotificationReceivedBundleIdentifier’ was not declared in this scope
如何访问和记录此NSString?
答案 0 :(得分:2)
您可以使用objective-c运行时功能并查看方法object_getInstanceVariable(the_object, "_lastNotificationReceivedBundleIdentifier", (void**)&yourPointer);
答案 1 :(得分:0)
另一个可以尝试的解决方案是:
[self valueForKey:@"lastNotificationReceivedBundleIdentifier"];
其中self
是父对象,lastNotificationReceivedBundleIdentifier
是变量名。例如与self.lastNotificationReceivedBundleIdentifier
相同。