Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Expected expression before '{' token"

I may be missing something silly. But I've been staring at it for a day now and re-working it and what not. I still get the same "Expected expression before '{' token" error.

Before I got this error I was having trouble getting my button to do what I was asking it to do, which was simply add the two numbers and display the answer, basically. Here's the bit of code giving me the problem:

-(IBAction)click:(id)sender {   
    int sum = [myInt1.text intValue] + [myInt2.text intValue];
    label.text = {NSString stringWithFormat:@"%@ the answer is %d",
        name.text, sum];
}
like image 290
jxd215 Avatar asked Aug 28 '26 01:08

jxd215


1 Answers

Replace:

label.text = {NSString ...

with:

label.text = [NSString ...

(the parenthesis before NSString).

like image 183
Eimantas Avatar answered Aug 30 '26 23:08

Eimantas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!