Hi folks.
I'm sure this is pathetically basic, but I'd appreciate a pointer. I've
been working with XCode 2 for a while, and a line like
NSString string = [NSString string];
would compile quite happily. Now, though, it throws an error warning of
the form
"statically allocated instance of Objective-C class NSString".
Now, I know (vaguely) what static and dynamic casting are, but have had
not had this issue before. I've tried the indexes of the various books
I have, and have tried the help menu in XCode.
Dave Seaman - 14 Jul 2008 23:07 GMT
> Hi folks.
> I'm sure this is pathetically basic, but I'd appreciate a pointer. I've
> been working with XCode 2 for a while, and a line like
> NSString string = [NSString string];
> would compile quite happily. Now, though, it throws an error warning of
> the form
> "statically allocated instance of Objective-C class NSString".
> Now, I know (vaguely) what static and dynamic casting are, but have had
> not had this issue before. I've tried the indexes of the various books
> I have, and have tried the help menu in XCode.
In Cocoa, all objects are dynamically allocated. In other words, you
have to write
NSString *string = [NSString string];
assuming that what you wanted was to make "string" point to an empty
instance of NSString that can't ever be changed (because it's immutable).

Signature
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
Andrew - 14 Jul 2008 23:10 GMT
>> Hi folks.
>> I'm sure this is pathetically basic, but I'd appreciate a pointer. I've
[quoted text clipped - 18 lines]
> assuming that what you wanted was to make "string" point to an empty
> instance of NSString that can't ever be changed (because it's immutable).
Right - got it now. Thanks!
Pascal J. Bourguignon - 14 Jul 2008 23:33 GMT
> Hi folks.
> I'm sure this is pathetically basic, but I'd appreciate a
[quoted text clipped - 10 lines]
> had not had this issue before. I've tried the indexes of the various
> books I have, and have tried the help menu in XCode.
This has nothing to do with typing (static or early typing vs. dynamic
or late typing).
This comes from C terminology. Variables that are allocated once at
the beginning of the program and live forever are called in C 'static'
variables. When their visibility is limited to the compilation unit
they are declared as:
'static' <type> <ident> [ '=' <initializer> ] ;
But when they are visible outside of the compilation unit, the
'static' keyword is droped. But they are still "static", with a
link-unit scope.
This warning is to tell you that this object is allocated when the
static variables are initialized. There is potentially problem with
that, because the order of initialization of these static variable
cannot be ensured by the compiler and linker, hence allocating and
initializing an Objective-C object at that time may require other
classes or objects that have not been initialized yet.

Signature
__Pascal Bourguignon__ http://www.informatimago.com/
The world will now reboot. don't bother saving your artefacts.
Tom Harrington - 15 Jul 2008 00:14 GMT
> Hi folks.
> I'm sure this is pathetically basic, but I'd appreciate a pointer. I've
[quoted text clipped - 3 lines]
>
> would compile quite happily.
You're sure you didn't use this in the past?
NSString *string = [NSString string];

Signature
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
Andrew - 15 Jul 2008 01:19 GMT
>> Hi folks.
>> I'm sure this is pathetically basic, but I'd appreciate a pointer. I've
[quoted text clipped - 7 lines]
>
> NSString *string = [NSString string];
Yeah - you're right. I'd forgotten that asterisk thing
Gregory Weston - 15 Jul 2008 02:07 GMT
> Hi folks.
> I'm sure this is pathetically basic, but I'd appreciate a pointer.
That sentence is funny. Know why?
> I've been working with XCode 2 for a while, and a line like
>
[quoted text clipped - 4 lines]
>
> "statically allocated instance of Objective-C class NSString".
Because you forgot the '*'.
G

Signature
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
Andrew - 15 Jul 2008 11:39 GMT
>> Hi folks.
>> I'm sure this is pathetically basic, but I'd appreciate a pointer.
[quoted text clipped - 13 lines]
>
> G
Yeah - realise that now - along with the unintended pun ;-)
P. Sture - 23 Jul 2008 09:42 GMT
> > Hi folks.
> > I'm sure this is pathetically basic, but I'd appreciate a pointer.
>
> That sentence is funny. Know why?
Very funny indeed :-) Well spotted.
> > I've been working with XCode 2 for a while, and a line like
> >
[quoted text clipped - 8 lines]
>
> G

Signature
Paul Sture