FROM : Clark S. Cox III
DATE : Fri Aug 01 21:24:10 2008
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:
[<email_removed>:~]% cat test.m
#import <Cocoa/Cocoa.h>
int main()
{
NSString s;
return 0;
}
[<email_removed>:~]% 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_removed>
DATE : Fri Aug 01 21:24:10 2008
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:
[<email_removed>:~]% cat test.m
#import <Cocoa/Cocoa.h>
int main()
{
NSString s;
return 0;
}
[<email_removed>:~]% 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_removed>
| Related mails | Author | Date |
|---|---|---|
| Wayne Shao | Aug 1, 20:43 | |
| Ken Thomases | Aug 1, 20:47 | |
| Clark S. Cox III | Aug 1, 20:54 | |
| Glenn English | Aug 1, 21:10 | |
| Jens Alfke | Aug 1, 21:18 | |
| Clark S. Cox III | Aug 1, 21:24 | |
| Arthur Coleman | Aug 1, 21:38 | |
| Clark Cox | Aug 1, 22:01 | |
| Giulio Cesare Sola… | Aug 1, 22:07 | |
| Clark S. Cox III | Aug 1, 22:15 | |
| Glenn English | Aug 1, 22:20 | |
| Michael Ash | Aug 1, 22:47 | |
| Sherm Pendley | Aug 1, 23:07 | |
| Daniel Staal | Aug 2, 00:27 | |
| Negm-Awad Amin | Aug 2, 09:05 | |
| Negm-Awad Amin | Aug 2, 09:09 | |
| mm w | Aug 2, 18:50 | |
| mm w | Aug 2, 20:19 | |
| Keary Suska | Aug 2, 22:53 | |
| Negm-Awad Amin | Aug 4, 08:31 |






Cocoa mail archive

