• 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
C Structs as objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C Structs as objects?


  • Subject: C Structs as objects?
  • From: Jeff LaMarche <email@hidden>
  • Date: Wed, 17 Oct 2001 09:07:08 -0700

I haven't seen anything documented about this in "Object Oriented Programming and the Objective-C Language", but it seems that C-style structs such as NSRect and NSSize are much more user friendly than structs in plain old C. For example:

Project builder allowed me to do this (this is from memory, so forgive me if it's not quite right):

NSSize mySize;

mySize = [myWindow frame].size;


In C, IIRC, you could absolutely not assign a struct to a struct simply by saying

destStruct = srcStruct;

You would have to copy the individual members or do a block copy or some other not-particularly-intuitive copy method.

Does this mean that structs behave as objects much as if they were actually objects subclassed from NSObject, or does it just that Objective-C has extended C by allowing this more intuitive manner of assigning structs to structs?


  • Follow-Ups:
    • Re: C Structs as objects?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Offscreen work
  • Next by Date: Re: What happens to the AppKit Framework when an user logout ?
  • Previous by thread: Re: Security Issue ... was[What happens to ...]
  • Next by thread: Re: C Structs as objects?
  • Index(es):
    • Date
    • Thread