Newbie question. Looking at arrays (ie: dynamically sized) this works:
NSArray *array;
array = [NSArray arrayWithObjects:
@"one", @"two", nil];
This does not:
array = [NSArray arrayWithObjects:
1, 2, nil];
Ok, I get it. This works:
array = [NSArray arrayWithObjects:
[NSNumber numberWithInt:1], [NSNumber numberWithInt:2], nil];
Its sorta less "on the fly" as C++ / Java. I see the same thing with the init examples I'm reading. For example:
// pseudo objc example
MyVar v = [MyVar init]; // blank
[v setSomething];
[v setSomethingElse];
// use v down here
In C++/Java I'd do:
MyVar v = new MyVar("foo", "bar", "baz", "quux");
And I'd know that v is ready to go by default. Is there a spirit of ObjC that I should not fight? Should I just expect to write more lines and less "one-liners"?