• MorphOS Developer
    jacadcaps
    Posts: 3018 from 2003/3/5
    From: Canada
    Quote:

    Georg wrote:
    Is error checking not needed with Objective-C? If the group object "g" is successfully created, but the window object "w" is not, will "g" still be freed?



    As with DoMethod() calling a method on an ObjC object via [] is safe on a null pointer. In the above example, group 'g' is allocated in an autoreleased state (meaning it will be freed once you exit the scope, unless you retain it - in this particular case it'd happen in [mapp run]). If window fails to allocate, w.rootObject = g; will do nothing (it's an equivalent of [w setRootObject:g]) and so the group 'g' will remain in autoreleased state. Afterwards [mapp instantiateWithWindows:w, NULL]; will fail since MUI requires at least one window to create an Application object.

    Quote:

    What happens if an app subclasses a MUI class and adds some method with name XYZ and then some year later the MUI base class is extended and now also adds a method with same name?


    That could be a problem. A good practice is to use prefixes for your own methods.
  • »21.12.20 - 15:15
    Profile Visit Website