objective c - uninitialized extern NSString usage -


in following class:

mgtilemenu

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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -