gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NIB loader: custom views don't draw themselves


From: Luboš Doležel
Subject: Re: NIB loader: custom views don't draw themselves
Date: Fri, 09 Aug 2013 12:18:10 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7

On 08/09/2013 11:05 AM, Luboš Doležel wrote:
> Is it possible that there are two different selectors with the same name
> in the system, one invokes the superclass' implementation and the other
> one invokes the the subclass' implementation?
> 

Okay, this is now confirmed.

This code works as expected:

#include <Foundation/NSObject.h>
extern "C" void testMe(id c)
{
        id obj = [c alloc];
        [obj initWithFrame: 0];
}

If I add #include <AppKit/NSView.h>, the the compilation starts failing
(clang).

error: no viable conversion from 'int' to 'NSRect' (aka '_NSRect')
/usr/local/include/AppKit/NSView.h:161:31: note: passing argument to
parameter 'frameRect' here
- (id) initWithFrame: (NSRect)frameRect;

Which is quite interesting, because I never stated that "obj" is of type
NSView*, it is still just "id". Is it legal for compiler to assume that?

And once I correct the compile error and supply a NSRect() in arguments,
then things break and initWithFrame: in class "c" is not invoked any
more. initWithFrame: in super class (NSView) is invoked instead.

I assume that this has something to do with typed selectors, since the
type info used for initWithFrame: in the subclass is different.

But is this behavior correct? I assumed that type information was only
supposed to be used for runtime checks (warnings) and shouldn't affect
where the message gets delivered.

-- 
Luboš Doležel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]