How to pass string args to method in obj-c
My method is look like this
+ (NSString *)开发者_开发百科textByPrefLang:(NSString*)Col:(NSString*)prefLang:(NSString*)tag {
return something;
}
How do I call that from another class?
in .h file:
+ (NSString *)textByPrefLang:(NSString*)Col withPrefLang:(NSString*)prefLang withTag:(NSString*)tag;
In Implementation .m Class
+ (NSString *)textByPrefLang:(NSString*)Col withPrefLang:(NSString*)prefLang withTag:(NSString*)tag {
return something;
}
When you call.
NSString* message = [MyClass textByPrefLang:@"col" withPrefLang:@"en" withTag:@"tag"];
It's as easy as this:
1.) Import the class so it's available to you.
#import "YourClass.h";
2.) Call the method like this:
NSString *response = [YourClass textByPrefLang:@"aString" Col:@"anotherString" prefLang:@"andAgainAString"];
The returned value will now be saved in the response
variable.
I hoped this helped you.
Sandro Meier
精彩评论