swift - CoreData: Not null property should be optional? -


i'm not sure best practice of swift , coredata. think not null property should optional basically?

for example

import foundation import coredata  class item: nsmanagedobject {     @nsmanaged var itemid: string // not null property     @nsmanaged var itemprice: string? // null possible } 

i wonder should notify other programmers property not-null or not.

i know do usually. question sound opinion-based i'm sure how dealing optional helpful others.

fyi found similar question

coredata - setting property of entity not null - should attribute set optional or mandatory

from https://developer.apple.com/library/mac/documentation/cocoa/conceptual/coredata/articles/cdmom.html#//apple_ref/doc/uid/tp40002328-sw6 .. mentioned - can specify attribute optional—that is, not required have value. in general, however, discouraged doing so—especially numeric values (typically can better results using mandatory attribute default value—in model—of 0)


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -