I just updated my Mac to Xcode 15 beta 6 and I find when I created a new view, The code is shown below: NSView * view = [[NSView alloc] init]; NSLog(@"%@",NSStringFromRect(view.visibleRect)); Console output {{-8.9884656743115785e+307, -8.9884656743115785e+307}, {1.7976931348623157e+308, 1.7976931348623157e+308}} But this has always been {0,0,0,0}
Xcode 15 beta 6 a new NSView visibleRect are not {0,0,0,0}, but {{-8.9884656743115785e+307, -8.9884656743115785e+307}, {1.7976931348623157e+308, 1.7976931348623157e+308}}
It has always been the case (AFAICR) that the designated initializers for NSView
are initWithFrame
and initWithCoder
, so use initWithFrame
and specify a zero-size rect.
As with many Obj-C framework classes, the plain init
initializer that's inherited from NSObject
isn't specifically disallowed, but there's no guarantee of the behavior you get and they generally should not be used when not documented.
Event if I use the initWithFrame function, the result remains the Same,But in previous versions, this result should be 0.
We are seeing the same behavior in our case the view is created by loading a NIB file. If we check "Prefers coder at runtime" for the NIB file, the values are meaningful but if that isn't checked, same problem but only with Xcode 15, no problem with Xcode 14.2, which may be related to the SDK being used and also note that our minimum deployment target is 10.13
Update
Spoke too soon. "Prefers coder at runtime" does not really fix the issue, it just prevents some custom UI elements from getting correctly initialized at all and then the UI that would run into the issue is simply missing. So that's not a solution either.
We're also seeing a miscalculated visibleRect on Xcode 15.0.1 with minimum deployment target of 10.13. Have you filed a bug report?