iOS-删除对我已删除的属性的引用 [英] iOS - removing reference of a property I had deleted
问题描述
我之前创建了一个按钮作为IBAction
,并将其命名为"hi".我从 .h 和 .m 文件中手动删除了代码,并从情节提要中删除了按钮,现在出现以下错误:
I had created a button earlier as an IBAction
and named it 'hi.' I manually deleted the code from my .h and .m file, and deleted the button from the storyboard and now I'm getting the error below:
2014-02-08 18:31:53.135 MadLibs2 [7645:70b] * 由于以下原因终止了应用 未捕获的异常"NSUnknownKeyException",原因: '[setValue:forUndefinedKey:]:此类 不符合密钥Hi的密钥值编码要求.'
2014-02-08 18:31:53.135 MadLibs2[7645:70b] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key hi.'
如何删除"hi"参考?
How do I remove the 'hi' reference?
// JBViewController.h
// MadLibs2
#import <UIKit/UIKit.h>
@interface JBViewController : UIViewController
// Properties manage an object's internal data
//// A properties data is stored in an instance variable or ivar (e.g., *sliderLabel)
// The property accesses ivars via getter/setter methods (aka accessors)
// put @property in front of the declaration of the ivar
// We access properties using the self keyword
@property (weak, nonatomic) IBOutlet UILabel *sliderLabel;
- (IBAction)sliderChanged:(id)sender;
- (IBAction)toggleShowHide:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *settingsView;
@property (weak, nonatomic) IBOutlet UISwitch *endingSwitch;
@property (weak, nonatomic) IBOutlet UILabel *petsLabel;
@property (weak, nonatomic) IBOutlet UIStepper *petsStepper;
- (IBAction)stepperChanged:(id)sender;
- (IBAction)createStory:(id)sender;
@end
// JBViewController.m
// MadLibs2
#import "JBViewController.h"
@interface JBViewController ()
@end
@implementation JBViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)sliderChanged:(id)sender {
UISlider *slider = (UISlider *)sender;
//why not NSInteger?
int numberAsInt = (int) (slider.value + 0.5f);
NSString *newText = [[NSString alloc] initWithFormat:@"%d", numberAsInt];
//self is used to access properties
/// What is 'text' used for? Is it a method?
self.sliderLabel.text = newText;
}
- (IBAction)toggleShowHide:(id)sender {
UISegmentedControl *segmentedControl =
(UISegmentedControl *)sender;
NSInteger segment = segmentedControl.selectedSegmentIndex;
if (segment == 0)
// self is used to access properties
[self.settingsView setHidden:YES];
else
[self.settingsView setHidden:NO];
}
- (IBAction)stepperChanged:(id)sender {
// update petsLabel to increase or decrease value
UIStepper *stepper = (UIStepper *) sender;
//NSLog([NSString stringWithFormat:@"%d",(int)stepper.value]);
int stepperNum = (int)stepper.value;
NSString *numPets = [[NSString alloc] initWithFormat:@"%d", stepperNum];
self.petsLabel.text = numPets;
}
- (IBAction)createStory:(id)sender {
}
@end
推荐答案
您应该选择该按钮,然后在连接检查器"中查找,引用应该出现在其中.
You should select the button and look in the "connections inspector", the reference should appear there.
这篇关于iOS-删除对我已删除的属性的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!