當我創造了我的故事情節進行UISwitch元素,並將其連接到.h文件中,有一個在控制器產生這一行:我應該使用IBAction來處理屏幕上可能發生的一切嗎?
@property (weak, nonatomic) IBOutlet UISwitch *wantHelp;
而我試圖找出如何使系統公告當值被改變,所以我想這樣的手動添加下面的東西原來的語句:
- (IBAction)wantHelp:(id)helpToggle;
,並在控制器中,我有這樣的事情:
-(IBAction)helpToggle:(id)sender
{
NSLog(@"sender is: %@", sender);
if (wantHelp.on)
{
NSLog(@"yes");
}
else
{
NSLog(@"No");
}
}
我想要做的是將helpToggle IBAction與特定的UISwitch元素連接起來,但是當我運行它時,出現一個錯誤:unrecognized selector sent to instance
,據我瞭解這意味着我調用了一個不正確的對象的操作。
有人能幫我理解我在這裏做錯了嗎?
謝謝!
這是我的.m文件看起來像:
@interface PlanBusinessController()
@end
@implementation PlanBusinessController
@synthesize businessDescription;
@synthesize personName;
@synthesize personEmail;
@synthesize privacy;
@synthesize wantHelp;
-(IBAction)helpToggle:(id)sender
{
NSLog(@"sender is: %@", sender);
if (wantHelp.on)
{
NSLog(@"yes");
}
else
{
NSLog(@"No");
}
}
你有它向後「,這是我理解的是意味着我叫一個不正確的對象上的操作。「你調用了一個對象不理解的操作(方法/選擇器),對象不理解(也沒有聲明) – 2012-07-13 19:23:29