Re: Newb: KATI Sample Code - What's This Called?
Re: Newb: KATI Sample Code - What's This Called?
- Subject: Re: Newb: KATI Sample Code - What's This Called?
- From: "Ken Ferry" <email@hidden>
- Date: Thu, 2 Oct 2008 21:05:04 -0700
On Thu, Oct 2, 2008 at 2:50 PM, Randall Meadows <email@hidden> wrote:
> On Oct 2, 2008, at 3:43 PM, Brad Gibbs wrote:
>
>> I'm working through the XSViewController example project from KATIDev and
>> I came across this line:
>>
>> [(ColorView*)[self view] setBackgroundColor:[[NSColor greenColor]
>> colorWithAlphaComponent:.5]];
>>
>> and realized I don't understand (ColorView*). It looks like it's
>> declaring a pointer to an object, but it's followed by a method. Could
>> somebody tell me the name of the function (ColorView*) is performing so I
>> can look it up and figure it out?
>
> That is casting the object returned from [self view] to a type of "pointer
> to a ColorView object", that is, an instance of a ColorView. Most likely,
> this is done to quiet a compiler warning about an object (in this case,
> whatever [self view] is returning, not responding to -setBackgroundColor:.
Parentheses do at least completely different in C. Three is just what
I can think of right now.
(1) Function invocation.
(2) Grouping.
(3) Casting.
Why does this code spew the odd sounding error message " called object
'argc' is not a function" when you try to compile it?
int main(int argc)
{
int argCount = argc
NULL;
return 0;
}
Because I forgot the semicolon after argc, and NULL expands to ((void
*)0). Those parentheses are intended for grouping, but to the
compiler it looks the same as
int argCount = argc((void*)0);
and it looks like I was trying to make a function call.
-Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden