我有一个NSError**类型的error变量,我想要获取error的error.description字段。有没有一种方法可以将它转换为NSError?
发布于 2019-11-23 01:12:18
NSError **是指向NSError *的指针。要访问底层NSError *,请使用*取消对它的引用。但是,只有当间接指针不为NULL时,这才是合法的。
if (error != NULL) {
NSString *desc = [*error description];
...
}说得更具体一点:
NSError **error = NULL; // Pointer to NULL
[*error description]; // Invalid and will crash.
NSError *underlyingError = nil;
[underlyingError description]; // This is fine and just returns nil
NSError **error = &underlyingError; // Pointer to a pointer
[*error description]; // This is fine and just returns nilhttps://stackoverflow.com/questions/58995813
复制相似问题