方法调用的参数太多,预期,1,有21

时间:2013-01-22 10:25:48

标签: objective-c compiler-errors nsstring arguments nsarray

当我使用此代码时,Xcode会给我一个错误:

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];

我应该使用它来避免错误吗?

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

Screenshot

2 个答案:

答案 0 :(得分:5)

您需要的方法是[NSArray arrayWithObjects:],而不是[NSArray arrayWithObject:]

请注意复数对象

答案 1 :(得分:4)

应该是-[NSArray arrayWithObjects:]你忘了' s '