Question

Trying my hand at the visual format language for iOS but I'm getting a sigabrt when trying to initialize the constraints. Any glaring issues with this code?

    NSNumber *inset = [NSNumber numberWithFloat:TopBarInsetWidth];
    NSNumber *width = [NSNumber  numberWithFloat:TopBarButtonWidth];
    NSNumber *height = [NSNumber numberWithFloat:TopBarButtonHeight];
    NSDictionary *metrics = NSDictionaryOfVariableBindings(inset,width,height);
    NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(self.backButton);
    NSArray *constraints =[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-inset-[self.backButton(=width)]|" options:0 metrics:metrics views:viewsDictionary];
Was it helpful?

Solution

For some reason Xcode was not giving me any kind of stack trace and was instead defaulting to sigabrting. I solved this by wrapping the code into try/catch blocks and breaking on the catch handler which then properly output my error.

OTHER TIPS

use this:

NSArray *constraints =[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-inset-[self.backButton(==width)]|" options:0 metrics:metrics views:viewsDictionary];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top