Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declaring floats in objective c

I'm new to Objective-C and I'm having trouble with the whole nonatomic, strong, weak, etc. I'm wondering if I will have any issues using Core Data with float values which are defined like so:

@property (nonatomic) float * rating;
@property (nonatomic) float * mRating;

Should I declare the differently?

like image 396
BlackHatSamurai Avatar asked May 22 '13 01:05

BlackHatSamurai


1 Answers

Yes, you should declare them without asterisks:

@property (nonatomic) float rating;
@property (nonatomic) float mRating;

Asterisks indicate pointers. All Objective C classes are declared with asterisks, because instances are referred to through pointers. Primitives such as floats, ints, etc. are defined as values, i.e. without asterisks. Same goes for typedef-ed types such as CGFloat and NSInteger: scalar fields of these types should be defined without an asterisk.

like image 193
Sergey Kalinichenko Avatar answered Nov 11 '22 06:11

Sergey Kalinichenko