• 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: [NEWBIE] Right way to make lightweight class/structs?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NEWBIE] Right way to make lightweight class/structs?


  • Subject: Re: [NEWBIE] Right way to make lightweight class/structs?
  • From: Chris Gehlker <email@hidden>
  • Date: Fri, 07 Sep 2001 07:42:49 -0700

On 9/6/01 6:09 PM, "Brian Hook" <email@hidden> wrote:

> I need to make some lightweight classes. The first one I'm encountering
> is my Vec3f class, which in C terms is just
>
> typedef struct
> {
> float x, y, z;
> } Vec3f;
>
> I don't want to make this a class because accessing everything through a
> get/set interface doesn't make much sense and would be grossly
> cumbersome. I'm tentatively just implementing everything in regular C
> interfaces, and that's been successful so far.
>
> When allocating memory for a chunk of Vec3fs, should I just use good old
> malloc() or is there an Obj-C equivalent to C++'s "new"? I can't use
> "alloc" since this isn't an NSObject.

It'd just leave it a struct and use malloc().

You can also use @public and access the ivars directly, just like public:
ivars in C++. I have to say, though, that public ivars make little sense to
me in C++ or ObjC. If a struct is the "right thing", us a struct.
--
In the midst of great joy, do not promise anyone anything. In the midst of
great anger, do not answer anyone's letter. -Chinese proverb


References: 
 >[NEWBIE] Right way to make lightweight class/structs? (From: Brian Hook <email@hidden>)

  • Prev by Date: NSToolbar wierdness
  • Next by Date: controlling buttons
  • Previous by thread: Re: [NEWBIE] Right way to make lightweight class/structs?
  • Next by thread: Re: [NEWBIE] Right way to make lightweight class/structs?
  • Index(es):
    • Date
    • Thread