Page 1 of 1

Translation needed

Posted: Sat Aug 17, 2019 11:03 am
by Wolfram
Can someone translate these swift code to PB?

Code: Select all

    let views = ["view": view]; 
                let horizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)
                superview?.addConstraints(horizontalConstraints)

Re: Translation needed

Posted: Sat Aug 17, 2019 12:40 pm
by wilbert
I'm not 100% sure but I think it should be something like this

Code: Select all

views = CocoaMessage(0, 0, "NSDictionary dictionaryWithObject:", view, "forKey:$", @"view")
horizontalConstraints = CocoaMessage(0, 0, "NSLayoutConstraint constraintsWithVisualFormat:$", @"H:[view]", "options:", 0, "metrics:", #nil, "views:", views)
CocoaMessage(0, superview, "addConstraints:", horizontalConstraints)