在目标c中声明浮动 [英] Declaring floats in objective c

查看:107
本文介绍了在目标c中声明浮动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Objective-C 的新手,而我在整个非原子时遇到了问题,等等。我想知道使用核心数据是否会出现任何问题 float 定义如下的值:

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?

推荐答案

是的,你应该声明它们没有星号:

Yes, you should declare them without asterisks:

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

星号表示指针。所有Objective C类都用星号声明,因为实例是通过指针引用的。诸如 float s, int s等原语被定义为 values ,即没有星号。对于typedef-ed类型也是如此,例如 CGFloat NSInteger :这些类型的标量字段应该没有星号来定义。

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.

这篇关于在目标c中声明浮动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆