Tips for debugging EXC_BAD_ACCESS

Jacob Carlborg doob at me.com
Mon Oct 15 01:04:38 PDT 2012


On 2012-10-14 22:58, Michel Fortin wrote:

> By
>>
> the way, that line is half-fishy:
>
>      super_struct.super_class = cast(objc.Class) OS.objc_msgSend(id, OS.sel_superclass);
>
> It'll
> work as long as you have only one level of derived classes, and only as
> long as you don't have a class that overrides the superclass method
> (which would be weird, I acknowledge). You should be aware of this if
> you're creating new object classes, especially the first part (the
> second part is only relevant if you wish to implement some kind of proxy
> objects).
>
> Theoretically, I think it'd be better to use directly functions from the
> Objective-C runtime[1], which also avoids the dynamic dispatch overhead
> of objc_msgSend:
>
>      super_struct.super_class = class_getSuperclass(object_getClass(id));

Thanks for the pointer. As a first step I'm only porting the Java code 
to D and this is how the Java code looks like. I'm trying to stay as 
close as possible to the Java code, making it easier to port future 
versions of SWT. But I also want the code to be correct.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list