ccgus / CocoaScript

JavaScript + the Cocoa frameworks, and then ObjC brackets show up to party as well.
Other
618 stars 58 forks source link

How to deal with many arguments #41

Closed onmyway133 closed 8 years ago

onmyway133 commented 8 years ago

Hi, some methods like - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation has many arguments, how to call them in cocoascript?

Thanks

ccgus commented 8 years ago

Check out the examples: https://github.com/ccgus/CocoaScript/blob/master/examples/NSImage%20Draw%20Buttons.jstalk

onmyway133 commented 8 years ago

@ccgus thanks. I see that we can use

var window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
      NSMakeRect(0, 0, 1365, 500), NSTitledWindowMask, NSBackingStoreBuffered, false)
zschuessler commented 7 years ago

@onmyway133 you just saved me from 90 minutes of headache, thanks for sharing what you found.

onmyway133 commented 7 years ago

@zschuessler Hope that it helps. Btw, if you're developing Sketch plugin, read my story here https://medium.com/@onmyway133/create-sketch-plugin-b97fb919e4c4#.qzfz04c38 on switching to using Objc framework