objective c - uninitialized extern NSString usage -
in following class:
various extern nsstring's defined in following way use notifications:
.h
extern nsstring *mgtilemenuwilldisplaynotification; // menu shown
.m
nsstring *mgtilemenuwilldisplaynotification;
it gets used follows:
[[nsnotificationcenter defaultcenter] postnotificationname:mgtilemenuwilldisplaynotification object:self userinfo:nil];
my question this: extern nsstring mgtilemenuwilldisplaynotification never gets initialized value - code works. have expected implementation in .m file be:
nsstring *mgtilemenuwilldisplaynotification = @"mgtilemenuwilldisplaynotification";
why not necessary , going on here?
this means actual variable defined in other parts of program. within framework or library. not have have related source.
the extern
keyword tells linker symbol table symbol named mgtilemenuwilldisplaynotification
. (i think static variable, not sure whether coud else.)
nsstring*
tells compiler tread memory pointer points nsstring
object. usual. declared somewhere else , probalby initialized somewhere else. in scope of responsibility ensure nsstring
object documentation of framework/library should tell you.
Comments
Post a Comment