ios - Converting an Objective-C #define macro to Swift -


i've got macro in objective-c project shortens typing long reference:

#define current_user dataconnector.sharedinstance.currentuser 

this allows me pass current_user in place of ^ reference current user.

how replicate in swift? i've tried this suggested let solution, appears creates variable immutable. using var appropriate instead? if #define instead:

#define const_str = static nsstring* const 

...which can used like:

const_str kxxsomeconstant = @"a constant string"; 

can swift let (or var?) solution used in same fashion?

it's understanding swift compiler not use c preprocessor, macros not possible. other commenters, suggest finding more swift-like way handle situation. macros have serious down-side, pointed out @originaluser2 in his/her comment. (not mention fatal flaw of being unsupported in swift.)


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -