2014年10月8日 星期三

CoreData的資料型態

我要的重點是decimal type是一種不會被四捨五入掉的小數型態!

節錄自這本書「Core Data iOS Essentials」

Types of attributes

Using the Type drop-down list control, we select the data type (that is, numerical, string, date, and so on) of the attribute to specify the kind of information that can be stored in the attribute. The following is the list of data types:
  • Integer 16, Integer 32, and Integer 64 data types are for storing signed integers. The range of values that these types are able to store is as follows:
    • Integer 16:-32,768 to 32, 767
    • Integer 32:-2,147,483,648 to 2,147,483,647
    • Integer 64:-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • Decimal, Double, and Float data types are for storing fractional numbers. The Double data type uses 64 bits to store a value while the Float data type uses 32 bits for storing a value. The only limitation with these two data types is that they round off the values. To avoid any rounding of values, the Decimaldata type is preferred. The Decimal type uses fixed point numbers for storing values, so the numerical value stored in it is not rounded off.
  • String data type is used for storing text contents.
  • Boolean data type is used for storing YES or NO values.
  • Date data type is used for storing dates as well as timestamps.
  • Binary data type is used for storing binary data.
  • Transformable data type works along with Value Transformers that help us create attributes based on any Objective-C class, that is, we can create custom data types other than the standard data types. This data type can be used to store an instance of UIColor, UIImage, and so on. It archives objects to instances of NSData.

沒有留言:

張貼留言