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
Post a Comment