想必我在這裏做錯了什麼,但是這段代碼看起來不起作用,我認爲它應該。任何人都可以發現我做錯了什麼,或者這可能是一個編譯器錯誤?爲什麼我無法捕捉到這個Swift異常?
一個異常不一定得到由它拋出不被逮住
根據拋出一個異常文檔:
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.
@johnykumar,這不是多麼迅速的作品。你有一個'do'塊,你可以在呼叫站點使用'try'。這句話是正確的 –
@GabrielePetronella謝謝兄弟我還沒有看到這是一個警告。我沒有太多家庭與迅速。 –