• 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: RFC: Allocating via a protocol/interface
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: Allocating via a protocol/interface


  • Subject: Re: RFC: Allocating via a protocol/interface
  • From: Charles Jolley <email@hidden>
  • Date: Tue, 2 Jul 2002 09:06:29 -0500

On Tuesday, July 2, 2002, at 12:32 AM, Michael Gersten wrote:

The goal is to be able to allocate a class that isn't known at compile
time, based on the output of a function.

A class is actually a struct. You could malloc one and use
objc_addClass() to add it to the runtime. There may be an easier way to
do this.

Ok, misunderstanding. I don't want to create a new class structure.
I want to create an instance of a class.

But when I'm writing my code, I don't know what class it will be. I
know the API that I want to use. I know the properties that I want to
use.

Add profiles for every class in each bundle to the bundle's Info.plist. The profiles could be anything you want. Keep a central registry object (so it is accessible in Java) that loads up all the profiles from your bundle. You could even delay loading the bundle itself until one of the classes defined by a profile is called upon. For a working example of this (or something pretty close), see OFRegistration in the OmniFoundation frameworks. (Check out omnigroup.com)

I don't know if you know this, but a Class can be treated much like an object. It can be stored in arrays, returned by dictionaries, etc. You can also convert a string containing a class name to the class by using NSClassFromString() (I think...)

-C
_______________________________________________
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.

References: 
 >Re: RFC: Allocating via a protocol/interface (From: Michael Gersten <email@hidden>)

  • Prev by Date: Re: Tips for using template C++ classes and Cocoa
  • Next by Date: Re: Drag-n-Drop to NSButtonCells in a NSMatrix?
  • Previous by thread: Re: RFC: Allocating via a protocol/interface
  • Next by thread: Re: RFC: Allocating via a protocol/interface
  • Index(es):
    • Date
    • Thread