• 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: Annoying Superclass Implemenation Warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Annoying Superclass Implemenation Warning


  • Subject: Re: Annoying Superclass Implemenation Warning
  • From: Steve Christensen <email@hidden>
  • Date: Mon, 21 Jan 2008 15:52:46 -0800

Chris Hanson educated me on this topic awhile back when I was trying to make an common Obj-C class part of a static library which was then linked into multiple plugins. To quote him:

You have thus far been able to get away with using a static library for this approach only because you haven't been using Objective-C. Once you start using Objective-C, you will not be able to use a static library, because while C++ classes are not objects and have little associated runtime data structure associated with them, Objective-C classes are objects and are associated with substantial runtime data structures. You cannot have the same class registered in the same runtime multiple times, which is what would happen if you had two plug-ins link your static library and get loaded into the same application.


You're basically in the same boat. When your plugin #1 loads, the common class is registered with the Obj-C runtime. When plugin #2 loads, you get the warning message that says you've already registered the class once. Another build phase won't help you out.

What Mike had suggested doing is to create a target that builds a framework containing the common class. Your plugin targets are then dependent on that target and also link against the framework it builds. When you install, your plugins go in the prefs panes folder and the custom framework goes in the frameworks folder. Then when plugin #1 loads, it forces the framework to load and register the common class. When plugin #2 loads, the class has already been registered, once, by the framework so there's no second attempt at registration.

steve


On Jan 21, 2008, at 3:17 PM, Ben Einstein wrote:

I understand why the message is occurring, I'm just not sure the appropriate way to get rid of it. The plugin build fails if I remove the superclass from the plugin target and place it in the main app target (can't find class symbol). Do I need to add another build phase?

Ben

On Jan 21, 2008, at 6:03 PM, Mike Abdullah wrote:

Well the message means exactly what it says: You've implemented the class in multiple plugins. Thus, the ObjC runtime cannot be sure which implementation to use. I would suggest you place the superclass within the main framework/application that the plugins are built against.

Mike.

On 21 Jan 2008, at 22:20, Ben Einstein wrote:

Hi All:

I have 15 or so preference panes implemented in my own preference pane viewer. Because the app started with only 2 or 3 panes, every pane had 6 or 7 identical methods. I had some free time this weekend and made a superclass to handle this dull pane stuff. I now get this annoying message in the console every time a user switches between panes:

objc[5347]: Class <SuperclassName> is implemented in both /Path/ To/Preference/Pane1/PaneName1 and /Path/To/Preference/Pane2/ PaneName2. Using implementation from /Path/To/Preference/Pane1/ PaneName1.

Any ideas to get the console to shut up? Not sure what I'm doing wrong.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Annoying Superclass Implemenation Warning
      • From: Ben Einstein <email@hidden>
    • Re: Annoying Superclass Implemenation Warning
      • From: Chris Hanson <email@hidden>
References: 
 >Leopard - interaction with Spaces from own applications (From: Dennis Schmidt <email@hidden>)
 >Re: Leopard - interaction with Spaces from own applications (From: Mike Abdullah <email@hidden>)
 >Re: Leopard - interaction with Spaces from own applications (From: glenn andreas <email@hidden>)
 >Re: Leopard - interaction with Spaces from own applications (From: Twisted Theory Software <email@hidden>)
 >Annoying Superclass Implemenation Warning (From: Ben Einstein <email@hidden>)
 >Re: Annoying Superclass Implemenation Warning (From: Mike Abdullah <email@hidden>)
 >Re: Annoying Superclass Implemenation Warning (From: Ben Einstein <email@hidden>)

  • Prev by Date: Re: Annoying Superclass Implemenation Warning
  • Next by Date: Re: Using assembly in objective-c
  • Previous by thread: Re: Annoying Superclass Implemenation Warning
  • Next by thread: Re: Annoying Superclass Implemenation Warning
  • Index(es):
    • Date
    • Thread