【发布时间】:2012-11-04 21:41:30
【问题描述】:
我正在制作我的第一个 iPhone 应用程序,并尝试从另一个类函数访问一个类函数。为什么这不起作用?
基本上我有两个类,“DateViewController”和“inputMilesViewController”。在“DateViewController”中,我从日期指针中获取日期并将其转换为字符串,我想将其发送到“inputMilesViewController”中的函数,该函数将更改该场景中按钮上的标签以显示传入的字符串.
在 DateViewController.m 中,我输入了 #import "inputMilesViewController.h" 我试过做
[inputMilesViewController changeButtonText:msg];
*我无法通过错误消息“选择器'changeButtonText:'没有已知的类方法:”
inputMilesViewController.m 有以下...
-(void) changeButtonText:(NSString*) dateStringForInput{
NSLog(@"we got to changebuttontext");
//[_myTodayButton setTitle:dateStringForInput forState:UIControlStateNormal];
}
现在我不太关心实际更改文本,我只是想让它打印这个 NSLog,这样我就知道我可以进入这个函数了。
【问题讨论】:
-
最好有一个简短的标题。也请不要使用签名等。
-
您需要先了解类和对象之间的区别,然后您才能理解错误的含义。
标签: iphone xcode class function methods