开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜