• 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
objectifying a struct
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

objectifying a struct


  • Subject: objectifying a struct
  • From: Keith Ray <email@hidden>
  • Date: Sat, 4 Feb 2006 16:37:46 -0800

In C/C++ legacy code, I can incrementally refactor C code using
structs in C++ code using classes. First by declaring constructors and
moving initialization code into the constructors. Then, replacing
usage of "malloc" and "free" with "new" and "delete". Then declaring a
destructor (if necessary); moving other code into methods, and
eventually declaring the member variables private and creating public
accessors/mutators for them (if needed). Since the only difference
between the declaration of "struct" and "class" in C++ the default
accessibility of the members, it doesn't really matter when I change
that keyword in the declaration.

If I wanted to do something similar, but end up with an Objective-C
subclass of NSObject, what steps would you recommend?

It seems like changing the "struct" declaration to an "interface"
declaration immediately breaks a lot of code because the member
variables immediately become private, but it has to be done earlier
than in C++, in order to declare "init" and other methods.

--

C. Keith Ray
<http://homepage.mac.com/keithray/blog/index.html>
<http://homepage.mac.com/keithray/xpminifaq.html>
<http://homepage.mac.com/keithray/resume2.html>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: objectifying a struct
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: Debugging with framework: symbols missing
  • Next by Date: Starting in Cocoa and a bit lost !
  • Previous by thread: Debugging with framework: symbols missing
  • Next by thread: Re: objectifying a struct
  • Index(es):
    • Date
    • Thread