Presumably I must be doing something wrong here, but this block of code does not seem to work and I think it should. Can anyone spot what I am doing wrong or might this be a compiler bug?
An exception does get thrown by it does not get caught
According to the docs an exception is raised:
Declaration
SWIFT
func valueForKey(_ key: String) -> AnyObject?
OBJECTIVE-C
- (id _Nullable)valueForKey:(NSString * _Nonnull)key
Parameters
key
The name of one of the receiver's properties.
Return Value
The value of the property specified by key.
Discussion
If key is not a property defined by the model, the method raises an exception. This method is overridden by NSManagedObject to access the managed object’s generic dictionary storage unless the receiver’s class explicitly provides key-value coding compliant accessor methods for key.