Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created August 27, 2013 10:48
Show Gist options
  • Save odrobnik/6352084 to your computer and use it in GitHub Desktop.
Save odrobnik/6352084 to your computer and use it in GitHub Desktop.
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
CGFloat topInset = 0;
CGFloat bottomInset = 0;
if ([self respondsToSelector:NSSelectorFromString(@"topLayoutGuide")])
{
id topLayoutGuide = [self valueForKeyPath:@"topLayoutGuide"];
topInset = (CGFloat)[topLayoutGuide length]; // 97
}
topInset = [self.topLayoutGuide length]; // 64
}
@0xced
Copy link

0xced commented Aug 27, 2013

Since topLayoutGuide is typed as id, the return type of the length message is guessed to be NSUInteger and the message is sent with the wrong ABI calling convention.

Try using your topLayoutGuide object actual class instead of casting the result to CGFloat, i.e.

LayoutGuide *topLayoutGuide = [self valueForKeyPath:@"topLayoutGuide"];
topInset = [topLayoutGuide length];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment