How to convert this CocoaScript “braces notation” to JavaScript “dot notation” (sketch)?

416 views Asked by At

How to convert these CocoaScript “braces notation” to JavaScript “dot notation” syntax?

[fileManager createDirectoryAtPath: tmpFolder withIntermediateDirectories: true attributes: nil error: nil];

and

[doc saveArtboardOrSlice: artboard toFile: fileName]

I've struggling with the CocoaScript “braces notation” format and want to use JavaScript instead combining them. I'm not sure if this even possible in all cases, like above. I get almost everything to work, but when I've syntax like above, I do not get it to right.

I tried something like:

var fileManager = NSFileManager.defaultManager();
fileManager.createDirectoryAtPath(tmpFolder).withIntermediateDirectories(true).attributes(nil).error(nil);

So I do not understand how to convert these "inner variables/properties", those which are e.g. "withIntermediateDirectories: true" to JavaScript dot notation syntax.

1

There are 1 answers

1
Roman Nurik On BEST ANSWER

The equivalent of:

[foo bar:1 baz:2];

is:

foo.bar_baz_(1, 2);