2

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.

Sakari Niittymaa
  • 403
  • 1
  • 3
  • 12

1 Answers1

6

The equivalent of:

[foo bar:1 baz:2];

is:

foo.bar_baz_(1, 2);
Roman Nurik
  • 29,665
  • 7
  • 84
  • 82
  • 1
    Thanks Roman! This leads me to right direction and got it to work properly. I didn't know about using "_" underscore marks in that way. So right syntax for my problem was: `fileManager.createDirectoryAtPath_withIntermediateDirectories_attributes_error(tmpFolder, true, null, null);` – Sakari Niittymaa Dec 27 '15 at 22:06