Re: Confusion
Re: Confusion
- Subject: Re: Confusion
- From: Charles Bennett <email@hidden>
- Date: Sun, 24 Jun 2001 17:28:48 -0400
Brian Howard wrote:
[munched]
>
So, if I get this right, we are both right in that from one viewpoint
>
I'm telling the compiler myName is of type NSString,
This is right, and the compiler will enforce this at compile time.
>
and from another
>
viewpoint myName is a pointer telling the compiler were to find out what
>
type myName is. Is that right? Six of one and half-a-dozen of another?
>
Nope. Quite the opposite, by using id you are telling the compiler NOT to
check what the type is beyond "Object".
That's why (as a very contrived, usless 4 lines)
id myName;
myName = [NSDictionary new];
myName = [NSArray new];
myName = [NSString new];
one, right after another, would all pass the compiler without complaint as
the compiler does not type check id, beyond Object (NSObject). In the
Olde day's of NeXTSTEP every function that didn't return "something" returned
(id) so methods that we now declare like
- (void) Foo {
}
used to be
- Foo {
return self;
}
so you had to know if you had to care about or ignore the returned "id"
- (void) is much cleaner in that you now "know" there is nothing of value
coming back.
>
Brian E. Howard
>
Cocoa Cult Central
>
maybe another step forward?
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
--
"I have great motivational skills. Everyones always saying how much harder they have to work when I'm around!"
-Homer S