user1996717
user1996717

Reputation: 65

too many arguments to method call, expected, 1, have 21

When I use this code, Xcode gives me an error:

NSArray *buttonsFiles = [NSArray arrayWithObject:@"button_plus.png",@"button_minus.png",@"button_multiple.png",@"button_div.png",@"button_eq.png",@"button_percent.png",@"button_sqrt.png",@"button_back.png",@"button_pointer.png",@"button_c.png",@"button_0.png",@"button_1.png",@"button_2.png",@"button_3.png",@"button_4.png",@"button_5.png",@"button_6.png",@"button_7.png",@"button_8.png",@"button_9.png",nil];

Should I use this instead to avoid the error?

NSString *myfile1 = [@"button_plus.png"];
NSString *myfile2 = [@"button_minus.png"];
...
NSString *myfile20 = [@"button_9.png"];
NSArray* myArray = [NSArray arrayWithObjects:myfile1, myfile2... myfile20r, nil];

Screenshot

Upvotes: 2

Views: 1252

Answers (2)

RolandasR
RolandasR

Reputation: 3047

it should be -[NSArray arrayWithObjects:] you forgot 's'

Upvotes: 4

colincameron
colincameron

Reputation: 2703

The method you need is [NSArray arrayWithObjects:], not [NSArray arrayWithObject:]

Note the plural Objects.

Upvotes: 5

Related Questions