swift - Core data Int16 as optional -


  1. in swift, how make nsmanaged int16 property optional this:

    nsmanaged var durationtype: int16?

    i'm getting compiler error: roperty cannot marked @nsmanaged because type cannot represented in objective-c

  2. if not possible, , check optional box in core data model editor, how check if property has value when coming database?

you can make property optional , keep int16. key @nsmanaged not required, if remove it, must implement own accessor methods.

one possible implementation:

var durationtype: int16?     {     {         self.willaccessvalueforkey("durationtype")         let value = self.primitivevalueforkey("durationtype") as? int         self.didaccessvalueforkey("durationtype")          return (value != nil) ? int16(value!) : nil     }     set {         self.willchangevalueforkey("durationtype")          let value : int? = (newvalue != nil) ? int(newvalue!) : nil         self.setprimitivevalue(value, forkey: "durationtype")          self.didchangevalueforkey("durationtype")     } } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -