• 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: "Clark S. Cox III" <email@hidden>
  • Date: Fri, 01 Aug 2008 12:24:10 -0700


On Aug 1, 2008, at 12:10 PM, Glenn English wrote:

Wayne Shao wrote:
It seems that every object is a pointer in the sample code I have
seen.  Is there any distinction between an object and its pointer?
In C++,  C* c; would be an uninitialized pointer. But the following
line will creates an object with the constructor C().
C c;
It seems that there is no such equivalent syntax in Objective-C.
objects are created either from factory pattern or  [[A alloc]
someInitMethod ....];
so, is it possible to write?
NSString a;
NSNumber b;

Sure. And it'll even compile. But you'd better not try to do much with them:-)

No, it won't compile:

[ccox@clarkco:~]% cat test.m
#import <Cocoa/Cocoa.h>

int main()
{
NSString s;

return 0;
}
[ccox@clarkco:~]% cc test.m
test.m: In function ‘main’:
test.m:5: error: statically allocated instance of Objective-C class ‘NSString’




--
Clark S. Cox III
email@hidden

_______________________________________________

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: pointers in objective-c?
      • From: Arthur Coleman <email@hidden>
References: 
 >pointers in objective-c? (From: "Wayne Shao" <email@hidden>)
 >Re: pointers in objective-c? (From: Glenn English <email@hidden>)

  • Prev by Date: Re: pointers in objective-c?
  • Next by Date: Re: Cocoa daemon
  • Previous by thread: Re: pointers in objective-c?
  • Next by thread: Re: pointers in objective-c?
  • Index(es):
    • Date
    • Thread