-existingObjectWithID:error:和-objectWithID:?的区别是什么? [英] What's the difference between -existingObjectWithID:error: and –objectWithID:?

查看:443
本文介绍了-existingObjectWithID:error:和-objectWithID:?的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-existingObjectWithID:error: -objectWithID:有什么区别?

推荐答案

objectWithID:假设对象存在,所以如果你给它一个坏的ID,它会抛出异常当您尝试访问返回的实体上的属性。

objectWithID: assumes the object exists so if you give it a bad ID it will throw an exception when you attempt to access a property on the returned entity. Also, this method always returns an entity.

existingObjectWithID:错误:将返回一个对象,如果它存在, code> nil 如果没有。如果有错误,它将填充错误指针。

existingObjectWithID:error: will return an object if it exists and nil if it does not. If there was an error it will populate the error pointer.

这篇关于-existingObjectWithID:error:和-objectWithID:?的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆