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
}
謝謝。那是非常快的。只要我被允許,我會盡快接受答案 –