Re: Incompatible pointer type from NSManagedObject's validateValue:forKey:error method
Re: Incompatible pointer type from NSManagedObject's validateValue:forKey:error method
- Subject: Re: Incompatible pointer type from NSManagedObject's validateValue:forKey:error method
- From: Cameron Hayne <email@hidden>
- Date: Mon, 23 Jan 2006 06:21:20 -0500
On 23-Jan-06, at 3:22 AM, Uli Kusterer wrote:
Am 23.01.2006 um 00:52 schrieb Cameron Hayne:
Looking in the NSManagedObject docs, I see that the signature of
that method is:
- (BOOL)validateValue:(id *)value forKey:(NSString *)key error:
(NSError **)error
which shows that the first argument is supposed to be of type (id
*) i.e. a pointer to an object, not an object itself.
Watch the typos there! You meant to write a pointer to a POINTER to
an object. id already is a pointer to an arbitrary object, and id*
thus is a pointer to a pointer. Tiny but important distinction that
can save one a lot of debugging
Well, actually it wasn't a typo, just an expression of how I think
about "objects".
In C++, I would have expressed it the way you did.
But in Obj-C (like in Java), I think of the pointers as *being* the
objects. I don't ever deal with the blob of memory directly - I only
deal with the blob via its pointer. So with for example, NSString *
foo, I think of foo as being the object. The fact that there is an
asterisk there in the declaration is just a notational curiosity - it
wouldn't make any sense to me to declare a variable NSString bar -
there is nothing I would use such a variable for.
I guess I change my way of thinking at a certain level of debugging
when it is useful to think of the nitty-gritty implementation-level
details. I have no difficulty in switching between these ways of
thinking according to the context. Nevertheless, you are probably
right that I should have maintained technical correctness when
explaining the reason for the compiler message to a beginner.
--
Cameron Hayne
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden