1

我想知道“_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?

4

2 回答 2

2

您可能可以使用objective-c 运行时功能并查看该方法object_getInstanceVariable(the_object, "_lastNotificationReceivedBundleIdentifier", (void**)&yourPointer);

于 2013-08-08T11:26:50.303 回答
0

另一个尝试的解决方案是:

[self valueForKey:@"lastNotificationReceivedBundleIdentifier"];

whereself是父对象,lastNotificationReceivedBundleIdentifier是变量名。例如与 相同self.lastNotificationReceivedBundleIdentifier

于 2018-09-10T09:39:25.163 回答