Why does
switch ([document currentTool]) { case DrawLine: NSBezierPath * testPath = [[NSBezierPath alloc]init]; //...rest of code that uses testPath....
result in
error:syntax error before '*' token
for testPath?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t instantiate an object inside a case statement unless you put it inside a new scope. This is because otherwise you could do something like this:
If you want the object to last for the duration of the case, you can do this:
This is the same in Objective C as well as C and C++.