如何从其类别中引用 View Controller 对象?

How to reference View Controller objects from it's category?

我有一个 iPad 应用程序,我为其中一个视图控制器创建了一个类别;我如何从类别中访问该视图控制器的 Storyboard scene 上的一些标签?

这是来自类别的代码:

    if( ([highValue compare: zero] == NSOrderedDescending) && ([lowValue compare: nines] == NSOrderedAscending) &&
   ([computedAverageValue compare:zero] == NSOrderedDescending))  {  //  if there are NO new books, don't display anything
    oHighPriceNew.text = [formatter stringFromNumber: highValue];
    oLowPriceNew.text = [formatter stringFromNumber: lowValue];
    oAveragePriceNew.text = [formatter stringFromNumber: computedAverageValue];
}

这是所有三个标签的错误:

Use of undeclared identifier 'oHighPriceNew'

它们在视图控制器中声明和连接...

我最终将所有 6 个参数传递给类别中的调用方法;工作正常。 @Shanti K 谢谢你的时间。我很感激。标准差

您需要使用

引用属性
self.oHighPriceNew.text = [formatter stringFromNumber: highValue];
self.oLowPriceNew.text = [formatter stringFromNumber: lowValue];
self.oAveragePriceNew.text = [formatter stringFromNumber:computedAverageValue];

_oHighPriceNew.text = [formatter stringFromNumber: highValue];
_oLowPriceNew.text = [formatter stringFromNumber: lowValue];
_oAveragePriceNew.text = [formatter stringFromNumber:computedAverageValue];