I'm learning about passing NSError
pointers and the book talks about the pointer "becoming" an instance of an NSError
.
I have no background in computer science but this seems wrong.
Does a pointer become an object, or does it point to a future allocation of memory that occurs at instantiation?
Does the object get initialized and the pointer remains where it is in memory?
And finally, what are the specific things that happen when an object instantiates specifically in the context of NSError
and the pointer I passed to the method?
This is wrong. The pointer remains a pointer. However, since all objects in Objective-C are referenced through pointers,
NSError
pointers are passed by double pointers, i.e.NSError**
:After you make this call when
errorCondition
is true,error
will be referencing a newly createdNSError
object, letting you pass a new instance back to the caller. This becomes handy when more than one object could be returned from a method invocation.