Carbon to Cocoa Conversion issues

I have recently purchased XOJO and started trying to update a RealStudio program from Carbon to Cocoa. I have a Nil Object exception on a class instance when I switch to Cocoa (runs in Carbon) . I am stumped. Feel pretty stupid. Any quick difference in setting up Classes with Cocoa ??


What is the situation where the code is throwing the exception?

There should be no difference so we need more information.

Without benefit of a stack trace, I’m going to be it is a event firing order issue that isn’t allowing one of your objects to initialize before the app/framework begins using it. We had a few like that a year ago during transition to Cocoa from Carbon.

IIRC one was an object used for drawing that wasn’t getting initialized before the window started making paint calls. We ended up adding a flag (global property) for such objects to avoid their use until after they initialized. The objects would flag themselves as usable at end of initialization. Just before start of destruction, the objects would be told to mark themselves as invalid. Client objects always check if objects are “valid” before use. That took care of problems with changes in startup event firing order.

Ironically, our fix was recently broken in 2013r3 because we didn’t realize that control global properties were reset after constructor. In a recent thread, we are reminded that one should use private or protected properties + a getter/setter, if such is done in constructor. For control initializations (that don’t need to passed parameters) the open event is a safer place to do initialization.

At any rate, under Cocoa, things that you assumed are completed under Carbon, might not yet have happened under Cocoa. Checking the objects before use is even more important under Cocoa.

Set the IDE to break upon exception and check the calling stack when the app has its nil problem. I’m sure you’ll track this down.

Thanks ! It did happen in a paint call. Sounds like what is happening.
It is going to be a lot of work, but i am going to attempt to get my Carbon
app running in cocoa.

Well, maybe not so much if i can get a handle on
the initializations…

Thanks again