-(IBAction)orderButtonPressed
{
myString = staterlabel1.text;
[myArray addObject:myString];
NSLog(@"wat is in %@",myArray);
}
-(IBAction)orderButton2Pressed
{
myString2 = staterlabel2.text;
[myArray addObject:myString];
NSLog(@"wat is in %@",myArray);
}
点击按钮后,myString
中的文字应添加到NSMutableArray
对象myArray
,但这不会发生。我做错了什么?
答案 0 :(得分:2)
你有一个错字
(IBAction)orderButtonPressed
{
myString = staterlabel1.text;
[myArray addObject:myString];
NSLog(@"wat is in %@",myArray);
}
-(IBAction)orderButton2Pressed
{
myString2 = staterlabel2.text;
[myArray addObject:myString2]; // <-- change here
NSLog(@"wat is in %@",myArray);
}
在第二种方法中,您需要添加myString2
而不是myString