0

There is any difference between:

#import <UIKit/UIKit.h>
const static NSString * name;
@interface AppDelegate : UIResponder <UIApplicationDelegate>


@end

and:

#import <UIKit/UIKit.h>
const  NSString * name;
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@end
joan
  • 2,407
  • 4
  • 29
  • 35
  • I think is not a duplicate. I dont ask the general case. I ask specically for a question related to the specific case of global variables declared static. – joan Mar 05 '15 at 14:40
  • The questions are exactly the same even in the title they are the same except that one has "What is the" at the beginning and yours has "on a variable" at the end. In what way aren't they the same question? – Popeye Mar 05 '15 at 14:43
  • Yes you are right, can I delete the question? – joan Mar 05 '15 at 14:51
  • There is no point you might as well allow it to be closed then the person who has answer still gets the rep – Popeye Mar 05 '15 at 14:52

1 Answers1

3

static means that the scope of the variable is limited to this compilation unit. Without it, you wouldn't be able to have two variables called NSString * name in two different implementation files (duplicate symbols).

Luke
  • 7,110
  • 6
  • 45
  • 74
  • 1
    This answer is to the point of the question, it answers the question for the scope in the sample code: file scope. – zaph Mar 05 '15 at 14:17
  • I used kPrefFcmClientId in AppDelegate.m and ViewController.m without using static. I got following error. duplicate symbol _kPrefFcmClientId. – John Nov 08 '19 at 13:18