Class 如何在类方法中使用@property?损失7

Class 如何在类方法中使用@property?损失7,class,methods,properties,ios7,instance,Class,Methods,Properties,Ios7,Instance,我得到了发送web请求的MyWebClass类方法,它得到了响应,我需要得到http头,所以我使用 @property NSHTTPURLResponse *response; 在MyWebClass类中,我需要使用 NSDictionary *headerDictionary = [response allHeaderFields]; 得到头球,但我不能,我怎么能解决它?我真的不想把那个类方法改成实例方法 该属性是在MyWebClass上定义的。如果该属性是在UIViewContr

我得到了发送web请求的MyWebClass类方法,它得到了响应,我需要得到http头,所以我使用

@property NSHTTPURLResponse *response;
在MyWebClass类中,我需要使用

    NSDictionary *headerDictionary = [response allHeaderFields];
得到头球,但我不能,我怎么能解决它?我真的不想把那个类方法改成实例方法


该属性是在MyWebClass上定义的。

如果该属性是在UIViewController上定义的,则可以使用:

NSDictionary *headerDictionary = [self.response allHeaderFields];
因为它是在MyWebClass中定义的,所以您可以这样做(假设它是单例):


因为“
response
”的public.h接口文件中定义了一个属性,所以您可以从应用程序中的任何位置访问它。当然,响应必须是非零的,才能从中获取所有头字段。

该属性是在MyWebClass上定义的,是MyWebClass的singleton还是属性或ivar(实例变量)?MyWebClass现在不是singleton,但稍后会是,它是发出请求并获得响应的类,它有1个带字符串的类方法:NSDictionary*headerDictionary=[response allHeaderFields];和1个属性:@property NSHTTPURLResponse*响应;
MyWebClass *myWebClass = [MyWebClass sharedInstance];
NSDictionary *headerDictionary = [myWebClass.response allHeaderFields];