Rewrite literal NSArray to compile on gcc for OS X 10.6

73 Views Asked by At

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?

1

There are 1 best solutions below

2
rmaddy On BEST ANSWER

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.