in my view controller.m i have a string like this
NSString *valueToSave = @"someValue";
and would like to safe the text with NSUserDefauls in Appdelegate.m
[[NSUserDefaults standardUserDefaults]
setObject:valueToSave forKey:@"preferenceName"];
how can i use the NSString in the other file?
This doesn’t work:
#import "viewcontroller.m";
In a header file have
extern NSString *valueToSave;. Then in a (1 and only 1) .m file haveNSString *valueToSave = @"someValue";A second option would be to use a #define. Simply put
#define kValueToSave (@"someValue")in a header file and use it where you need it.