Use of undectared identifier '_xxxx'
来源:互联网 发布:如何扩大交际圈 知乎 编辑:程序博客网 时间:2024/06/08 03:57
今天自定义一个继承UITextField的textField的时候,设置变量_borderColor的setter和getter方法的时候,出现了这样的报错
#import <UIKit/UIKit.h>IB_DESIGNABLE@interface CYSTextField : UITextField@property (strong, nonatomic) IBInspectable UIColor *borderColor;@property (assign, nonatomic) IBInspectable CGFloat borderWidth;@property (assign, nonatomic) IBInspectable CGFloat cornerRaduis;@end
单独设置setter方法的时候没有问题,但是加上getter方法的时候,xcode就会提示undectared identifier ‘_xxxx’这样的错误了。
- (UIColor *)borderColor{ if (!_borderColor) { return [UIColor blueColor]; } return _borderColor;}- (void)setBorderColor:(UIColor *)borderColor{ _borderColor = borderColor; self.layer.borderColor = _borderColor.CGColor;}
在上面加上 @synthesize borderColor = _borderColor;
后,问题就解决了。
度娘了一下,问题出现的原因应该是_borderColor 是变量,borderColor是属性。borderColor属性生成存取方法是setBorderColor和borderColor,这2个方法操作的变量是_borderColor
getter器的方法名直接就是变量名,方法名和变量名一样,容易让人迷糊,所以,可以这样优化
这样我们就去使用_xxxxx,像使用xxxxx一样。
0 0
- Use of undectared identifier '_xxxx'
- Use of undeclared identifier 'CHAT_SENDMESSAGE_STATUS'
- iOS - use of undeclared identifier
- Use of undeclared identifier 'OBJC_ASSOCIATION_RETAIN_NONATOMIC'
- xcode出现 use of undeclared identifier
- xmpp Use of undeclared identifier 'ddLogLevel'
- xmpp Use of undeclared identifier 'ddLogLevel'
- use of undeclared identifier 'xxxxxxx方法名'
- 添加.c文件报错 use of undeclared identifier , use of undeclared identifier等等
- Xcode 出现Use of undeclared identifier 'GL_BGRA_EXT'的解决
- SDWebImage 报错:Use of undeclared identifier _executing/_finished
- 导入AFN框架出现问题Use of undeclared identifier ‘kSecFormatUnknown’
- Use of undeclared identifier 'BMKMapPointMake'错误 (百度地图)
- Unity to iOS opengl error:Use of undeclared identifier 'GL_BGRA_EXT' ...
- iOS逆向 error: use of undeclared identifier 'MSHookIvar'
- 代码运行 出现 use of unresolved identifier“xxxxVC”
- stm32 keil中出现use of undeclared identifier' '的原因
- 解决IOS开发使用Lumberjack库时出现的Use of undeclared identifier 'ddLogLevel'问题
- html和css学习心得
- 欢迎使用CSDN-markdown编辑器
- Java NIO框架Netty教程(二) – 白话概念
- 周记——20150803
- 生活中常给自己的心理暗示:
- Use of undectared identifier '_xxxx'
- zoj 1395 Door Man 欧拉回路
- struts2整合json
- 牛客网做题总结:剑指offer中题目,java版二
- CSS3.0盒模型display:-webkit-box;的使用
- 新公司入职遇到的一件事
- C++中如何理解容器适配器
- DOS format was specified but only a single line feed character was found, not 2
- instance()