Why passing &error instead of error in Cocoa programming?

前端 未结 4 2066
刺人心
刺人心 2020-12-08 01:45

In Cocoa programming, when dealing with NSError, why we are passing &error to a message instead of error?

NSError *error;
if (![managedObject.managedObje         


        
4条回答
  •  北海茫月
    2020-12-08 01:48

    It's the address-of operator; it produces a pointer pointing to the referent. In this case, error is an NSError *,it takes an address to it and may modify error through that pointer to indicate the error that occurred.

提交回复
热议问题