1

I got a suggestion here on SO to write this line:

NSArray *files = @[url];

However my Xcode/gcc is outdated as I'm still using OSX 10.6.

How do I rewrite this line so that it will compile?

jscs
  • 63,694
  • 13
  • 151
  • 195
Igor
  • 5,620
  • 11
  • 51
  • 103
  • @JoshCaswell, I thought the official name is "XCode" and not the "Xcode". Am I wrong? I mean this is copyrighted stuff, so it has to be right. – Igor Dec 05 '15 at 19:35
  • They keep changing the capitalization; the latest version is "Xcode", but the one you have may indeed say "XCode". I edited it reflexively. Feel free to change it back if you like. – jscs Dec 05 '15 at 19:37
  • @JoshCoswell, Also the rewrite is to compile on OSX 10.6, not necessary run on that OS. So the title change is not literally correct. – Igor Dec 05 '15 at 19:37
  • That's what I intended the title to say; if you think it's confusing, again please feel free to re-edit, but please preserve the greater level of description over your original "how to change this line". – jscs Dec 05 '15 at 19:39

1 Answers1

1

If you need to use the old style Objective-C syntax you would write:

NSArray *files = [NSArray arrayWithObjects:url, nil];

or just:

NSArray *files = [NSArray arrayWithObject:url];

Look at the documentation for NSArray.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • @maddy, What is the difference between those 2? Does it matter which one to use? Thx. – Igor Dec 05 '15 at 19:17
  • The first is usually used when you have more than one object to put in the array. The second is used when you only have one object. In your case, either works. – rmaddy Dec 05 '15 at 19:18