0
对不起,听起来像一个noob,但我如何创建iPhone应用程序的目标C中的输入/输出功能。输入输出字符串函数
我想要做的是创建一个函数,我将它传递给一个字符串,字符串在函数中得到评估,然后返回一个字符串结果。
这是我迄今为止所做的,当然这是错误的,因为它没有编译。
在我的* .h文件void my_func(NSString *string);
在我的* .m文件
void my_func(NSString *string)
{
NSMutableString *statusBack;
if ([string isEqualToString:@"26"])
{
statusBack = [NSMutableString stringWithFormat: @"Sunny"];
}
else
{
statusBack = [NSMutableString stringWithFormat: @"Cloudy"];
}
return statusBack; //compile error
}
-(IBAction) customIBAction
{
//call my custom function
//not sure how?
NSMutableString *str1 = [NSMutableString stringWithFormat: @"24"];
NSString *returnedStr = my_func(str1); //compile error
}
谢谢。那是非常快的。只要我被允许,我会尽快接受答案 –