0

我有一个这样的头文件:

@class NSMutableDictionary, NSString;

@interface randomclassname : NSObject
{
    unsigned long long _HTTPMethod;
    NSString *_path;
    unsigned long long _apiVersion;
    NSMutableDictionary *_parameters;
    NSMutableDictionary *_defaultParameters;

    NSMutableDictionary *_headers;
    _Bool _isSigned;
}
/// methods are down here
+ (id)builderWithHTTPMethod:(unsigned long long)arg1 path:(id)arg2;

我想访问和打印NSMutableDictionary *_defaultParameters;

unsigned long long _apiVersion;

我的方法对象中的以下属性。

+ (id)builderWithHTTPMethod:(unsigned long long)arg1 format:(id)arg2 
{
    **access those properties here and print them on NSlog.**
    return %orig; 
}

如果我错了,请随时纠正我。我不完全确定@interface 中的东西是否称为属性;我正在猜测。但这就是我要访问的内容。

4

1 回答 1

0

首先,您需要_defaultParameters在 .h 文件中添加您和您的 apiVersion 作为属性

@property NSMutableDictionary *defaultParameters;
@property (assign) unsigned long long _apiVersion;

之后,您可以在您的方法中将参数 id 作为您的 randomclassname

+ (id)builderWithHTTPMethod:(unsigned long long)arg1 format:(id)arg2 
{
    //**access those properties here and print them on NSlog.**
    randomclassname *obj = (randomclassname*)arg2;
    NSLog(@"%@",obj.defaultParameters);
    return %orig; 
}
于 2018-02-17T06:18:46.823 回答