>类型’NSManagedObjectContext’不符合协议’BooleanType’.
>类型’NSManagedObjectModel’不符合协议’BooleanType’.
>类型’NSPersistentStoreCoordinator’不符合协议’BooleanType’.
还附有错误的屏幕截图.
解决方法
所以你正在处理Optionals.由于Beta 5 Optionals不再符合BooleanType协议.
您需要明确检查nil,更改:
if !_managedObjectContext { // ... }
至:
if _managedObjectContext == nil { // ... }
并为_managedObjectModel和_persistentStoreCoordinator执行相同的操作.
来自xCode 6 Beta 5发行说明:
Optionals can now be compared to nil with == and !=,even if the
underlying element is not Equatable.
和
Optionals no longer conform to the BooleanType (formerly LogicValue) protocol,so they may no longer be used in place of boolean expressions (they must be explicitly compared with v != nil). This resolves confusion around Bool? and related types,makes code more explicit about what test is expected,and is more consistent with the rest of the language. Note that ImplicitlyUnwrappedOptional still includes some BooleanType functionality. This issue will be resolved in a future beta.