• 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: Mixing Obj-C and C "methods"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixing Obj-C and C "methods"


  • Subject: Re: Mixing Obj-C and C "methods"
  • From: Michael Crawford <email@hidden>
  • Date: Tue, 30 Jul 2013 21:29:31 +0000

> The same is true for class methods, by the way.  If a class method has a reference to
> an instance of the class, it can directly access the instance's ivars the same way.

Objective-C shares a property with some languages, but not with
others, that classes are actual objects.

That is, if my code has "@interface Foo" and "@implementation Foo",
then in addition to possibly multiple instantions of Foo objects,
there is a _single_ Foo "class object".  That class object occupies a
non-zero quantity of memory, at its lowest level being somewhat like
the combination of a single copy of a C struct, as well as some C
functions, that from the Objective-C point of view, appear to be
"class methods" that know all about their "class object", but that are
not capable of (directly) operating on instances.

C++ has the concept of class member functions, as well as class data
members, but in the case of C++, it's all implemented purely by
scoping.  There is no actual class object.  Instead class member
functions know all about what is declared in the scope of the class,
but do not have access to "this".  Class data members, more or less,
are stored and implemented just like global data variables, as
individual items that are not, in general required to be actually
stored adjacent to each other in a single record.

Some of the really cool things that one can do with certain languages
other than C++, is to manipulate those class objects as if they were
some regular kind of data.  I can't come up with a meaningful example
for you just now though.

I'm not that familiar with Javascript, but my understanding is that
Javascript functions are actual objects, that are implemented by data
records stored in memory, rather than, as in C or C++, simply the
memory addresses of code entry points.

Michael David Crawford P.E., Process Architect
Solving the Software Problem
email@hidden
http://www.warplife.com/mdc/

   Don't Fix the Bugs.  Fix the People that _Cause_ the Bugs.
_______________________________________________

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: Mixing Obj-C and C "methods"
      • From: Andy Lee <email@hidden>
References: 
 >Mixing Obj-C and C "methods" (From: Vincent Habchi <email@hidden>)
 >Re: Mixing Obj-C and C "methods" (From: Rick Mann <email@hidden>)
 >Re: Mixing Obj-C and C "methods" (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: NSTrackingRect not always working
  • Next by Date: Any way to get a static table view to update its footer?
  • Previous by thread: Re: Mixing Obj-C and C "methods"
  • Next by thread: Re: Mixing Obj-C and C "methods"
  • Index(es):
    • Date
    • Thread