• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PlugIn behavior: Strange but Extremely Sexy!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PlugIn behavior: Strange but Extremely Sexy!


  • Subject: Re: PlugIn behavior: Strange but Extremely Sexy!
  • From: Drew McCormack <email@hidden>
  • Date: Sun, 27 Oct 2002 08:44:05 +0100

On Sunday, October 27, 2002, at 02:19 AM, email@hidden wrote:

I have been experimenting with PlugIns, and I have come across some interesting behavior:

There are three plugins: superPlugIn.bundle, superPlugInSubstitute.bundle, and subPlugIn.bundle;

The superPlugIn.bundle and superPlugInSubstitute.bundle both implement a class called SuperPlugIn that has one method: doSomethingCool that looks different for each implementation:

superPlugIn.bundle:

- doSomethingCool
{
NSLog(@"Hello World!"); //I know, that's not very cool.
}

superPlugInSubstitute.bundle:

- doSomethingCool
{
NSLog(@"!dlrow olleH"); //That's a little more like it!
}

The subPlugIn.bundle implements a class called SubPlugIn that does nothing but inherit from SuperPlugIn.

The program that these are loaded into checks for and then calls the doSomethingCool method of each class, so loading in superPlugIn.bundle and then subPlugIn.bundle produces:
Hello World!
Hello World!

Likewise, loading in superPlugInSubstitute.bundle and then subPlugIn.bundle produces:
!dlrow olleH
!dlrow olleH

The first strange thing is that subPlugIn.bundle can be loaded in without superPlugIn(Substitute).bundle being loaded in before it or even at all (though it doesn't produce anything, because there is no inherited method).

The second strange thing is that all three or both superPlugIn.bundle and superPlugInSubstitute.bundle can be loaded into the program at the same time without a class conflict (depending on the loading order, they put out their output).

Why are these two strange scenarios possible (and can they be reliably exploited?).
Is it always the case that a subclass loaded in doesn't need to have its superclass loaded in first (provided no message is sent to it)?

I have also been working with plugins, and I find something similar, namely it seems to be OK to have two implementations of the same class. You get a message in the console warning message, and one of the implementations gets chosen. But I also found that some uses of the class could cause serious errors: When I tried to call the +(Class)class method of the class with two implementations, my program crashed without any warning or error message.

Drew
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: PlugIn behavior: Strange but Extremely Sexy!
      • From: email@hidden
    • Re: PlugIn behavior: Strange but Extremely Sexy!
      • From: email@hidden
References: 
 >PlugIn behavior: Strange but Extremely Sexy! (From: email@hidden)

  • Prev by Date: Re: This is bullsheet
  • Next by Date: Re: Rule List Control?
  • Previous by thread: [OT] Re: PlugIn behavior: Strange but Extremely Sexy!
  • Next by thread: Re: PlugIn behavior: Strange but Extremely Sexy!
  • Index(es):
    • Date
    • Thread