Beginner struggles with Objective-C

I follow the objective-c book (objective-c basics of Fairbairns, Fahrenkrug, Ruffenach), and I fell to the first hurdle with their CoinToss example.

I get the "expected expression" error on this line:

๏ฟผ๏ฟผ๏ฟผresult.text = coinLandedOnHeads ? @"Heads" : @"Tails"; 

I also included a screenshot of the entire page below. what exactly is the problem ?: I checked and double-checked the code in the same way as the book, but did I miss something very obvious?

Thanks!

xcode window

EDIT: Here is my header file:

 #import <UIKit/UIKit.h> @interface ViewController : UIViewController { UILabel *status; UILabel *result; } @property (nonatomic, retain) IBOutlet UILabel *status; @property (nonatomic, retain) IBOutlet UILabel *result; -(IBAction)callHeads; -(IBAction)callTails; @end 
+4
source share
1 answer

I definitely know your problem.

The book is out of date. When you created the project, you selected the checkbox "Automatic link counting". This means that you do not need to do dealloc. This is not your mistake, Xcode just has a new automatic memory management feature, and the book is old enough, so it forces you to do it manually.

To fix this:

Delete the entire dealloc method

Or

Restart the project and do not check the box "Automatic link counting".

+2
source

All Articles