• 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: pointers in objective-c?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pointers in objective-c?


  • Subject: Re: pointers in objective-c?
  • From: "Sherm Pendley" <email@hidden>
  • Date: Fri, 1 Aug 2008 17:07:57 -0400

On Fri, Aug 1, 2008 at 3:38 PM, Arthur Coleman <email@hidden> wrote:
> I hate to be dense, but what about C structs like NSRect?

There's nothing special about them - they can be allocated on the
stack or on the heap, just like any other C struct.

> There are initialized on the stack aren't they?

Unlike instance variables, which are initialized to 0, 0.0, or nil,
when an object is allocated, stack variables are *not* initialized to
any particular value. That's why it's a good idea to initialize them
yourself when you declare them:

-(void)foo {
    id bar = nil;
    id baz;

    // Do stuff
}

In the above, bar will always be nil when you get to the "Do stuff"
code. But the value of baz will be whatever happened to be at that
location on the stack before you called -foo.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

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

References: 
 >pointers in objective-c? (From: "Wayne Shao" <email@hidden>)
 >Re: pointers in objective-c? (From: Glenn English <email@hidden>)
 >Re: pointers in objective-c? (From: "Clark S. Cox III" <email@hidden>)
 >Re: pointers in objective-c? (From: Arthur Coleman <email@hidden>)

  • Prev by Date: Re: Distributed Objects "connection went invalid while waiting for a reply"
  • Next by Date: Putting a spinning progress indicator in a outline
  • Previous by thread: Re: pointers in objective-c?
  • Next by thread: Re: pointers in objective-c?
  • Index(es):
    • Date
    • Thread