在NSArray中找到最大的矩形宽度

| 我正在使用包含0个值的1个值。有什么方法可以通过库方法来获得包含在数组中的所有rect的最大宽度,还是我必须实现自己的逻辑?提前致谢。 代码示例:
for (int i=0; i<[array1 count]; i++) {
    CGRect rect = [[array1 objectAtIndex:i] CGRectValue];
// Here, some transformation of rects

[array2 addObject:[NSValue valueWithCGRect:rect]];

}
在这段代码中,我尝试从
array1
中获取帧并将其添加到
array2
中。我正在从XML中获得“ѭ3”中的帧。我解析了这些帧并将它们放置在数组中。我以非常简单的方式提供了代码。     
已邀请:
请勿一遍又一遍地向您的阵列发送“ 6”消息。这很浪费。
float result = 0.0;
for (value in array1)
  {
  GCRect rect = [value CGRectValue];
  result = MAX(result, rect.size.width);
  }  // \"result\" now contains the greatest width you saw in the loop.
    
for(int i=0; i < [array2 count]; i++) 
{
    CGRect rect = [[array2 objectAtIndex:i] CGRectValue];
    float widthTest = rect.size.width;
    //this gives you the width of each element. Compare and get the biggest
}
    

要回复问题请先登录注册