im working on a old code and i have this warning message: Passed-by-value struct argument contains uninitialized data (e.g., via the field chain: 'origin.x'). If i could get dome help i would be very thankful :)
The code im using:
- (void)positionScroller
{
CGRect screenFrame = [[UIScreen mainScreen] bounds];
CGRect scrollerRect;
if( self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
{
scrollerRect = CGRectMake( 0, 0, screenFrame.size.width, screenFrame.size.height );
}
else if( self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight )
{
scrollerRect = CGRectMake( 0, 0, screenFrame.size.height, screenFrame.size.width );
}
_scroller.frame = scrollerRect; <---This is where the compiler gives the warning
}
Best Regards.
The thing is that the compiler can't be sure that one of the if/else-if blocks is ever reached, in which case, scrollerRect
would still be uninitialized. You should either add a pure else
statement or initialize scrollerRect
, e.g. by setting it to CGRectZero
.
By the way, this has nothing to do with a memory leak, it's more of a logic error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With