1

Hei all

i try to learn how i can get a NSString global, i have this kind of files.

( my global class )

Globals.h 
Globals.m

( my first view )

FirstViewController.h
FirstViewController.m

( my secound view )

SecoundViewController.h
SecoundViewController.m

now i will make a kind of username in FirstViewController and when SecoundViewController loads its will make my input into NSLog() in first time.

hobe i can be help here, :)

ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66

1 Answers1

3

If you truly want a global string, you can simply define it outside of any class definition, function, etc. in your Global class.

In Global.h:

extern NSString *globalString;

In Global.m:

NSString *globalString = @"a string";

To reference it in another class:

#import Global.h
...
NSString *aString = globalString;
...

If you simply want to pass a string from your first view to your second, look into properties.

thomashw
  • 956
  • 4
  • 7