I have define #define baseUrl [NSString stringWithFormat:@"%@api/v4", MAINURL]
in objective c class and can access anywhere in project. But now i have created swift file in exiting objective c project and want to access baseurl in swift but error received.
Use of unresolved identifier 'baseUrl'
how can resolve it?
The words employ and utilize are common synonyms of use. While all three words mean "to put into service especially to attain an end," use implies availing oneself of something as a means or instrument to an end.
Used to refers to something familiar or routine, as in "I'm used to getting up early for work," or to say that something repeatedly happened in the past like "we used to go out more." Use to typically occurs with did; "did you use to work there?" or "it didn't use to be like that," describing something in the past that ...
As detailed above, 'use' can be a noun or a verb. Noun usage: The use of torture has been condemned by the United Nations. Noun usage: There is no use for your invention.
Use refers to the act of using or state of being used for a purpose. Usage refers to an accepted and habitual practice or the customary manner in which a language or a form of language is spoken or written.
Importing Objective-C macros into Swift doesn't always work. According to documentation:
Swift automatically imports simple, constant-like macros, declared with the #define directive, as global constants. Macros are imported when they use literals for string, floating-point, or integer values, or use operators like +, -, >, and == between literals or previously defined macros.
C macros that are more complex than simple constant definitions have no counterpart in Swift.
An alternative in your case would be to use a function that returns the value defined by macro
// .h file
#define baseUrl [NSString stringWithFormat:@"%@api/v4", MAINURL]
+ (NSString*) BaseUrl;
// .m file
+ (NSString*) BaseUrl { return baseUrl }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With