Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails in Extension to NSView #66

Closed
drosenstark opened this issue Jan 25, 2015 · 3 comments
Closed

Fails in Extension to NSView #66

drosenstark opened this issue Jan 25, 2015 · 3 comments

Comments

@drosenstark
Copy link

Example of an NSView Category:

extension NSView {
    func sizeToFillSuperview() {
        layout(self) { view in
            view.size == view.superview!.size; return
        }
    }
}

Swift Compiler Error is "extra argument in call"

Early substitution for self doesn't help, nor does anything else I've thought of.

Obviously a global function like this is okay, but not ideal:

func sizeToFillSuperview(view: NSView) {
    layout(view) { box in
        box.size == box.superview!.size; return
    }
}

THANKS!

@robb
Copy link
Owner

robb commented Jan 25, 2015

Looks like layout is getting shadowed by NSView.layout inside NSView instance methods, hadn't realized this.

This should do the trick:

func sizeToFillSuperview(view: NSView) {
    Cartography.layout(view) { box in
        box.size == box.superview!.size; return
    }
}

@drosenstark
Copy link
Author

Ok, got it, thank you!

@robb robb closed this as completed Jan 25, 2015
@drosenstark
Copy link
Author

Hmmm... on the one hand, this is very simple. I must use Cartography as a separate .framework instead of including the sources directly in the Xcode project...

On the other hand, I'll have to open up another ticket about all my issues getting Cartography to work as a framework, whether via CocoaPods or just grabbing the .framework directory and pulling it in (runtime errors).

Thanks for your time and this framework!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants