There is a thing that while defining macro's i was using a objective c file. Lets say i define a macro as
#define TRY_THIS @"try_this"
Then i am using this macro to save a string in Swift file in defaults
NSUserDefaults.standardUserDefaults().setObject("12", forKey: TRY_THIS )
As i know, while compiling, macros just replace the TRY_THIS
to @"try_this"
. Lets say it is replaced :-
NSUserDefaults.standardUserDefaults().setObject("12", forKey: @"try_this" )
But "@"
is not used in swift , so should this give me error or not.
I am not sure. Can anyone tell me how to use a hash define strings of objective c in swift.
I am seeing that this command is working . Can you let me know why?
Also to get the value back i am using :-
NSUserDefaults.standardUserDefaults().stringForKey(TRY_THIS)
NSUserDefaults.standardUserDefaults().stringForKey("try_this")
Both should work while getting value back. If yes why. if not why ?
Please clarify my confusion.