You Can Customize Synthesized Instance Variable Names @property
As mentioned earlier, the default behavior for a writeable property is to use an instance variable called _propertyName.
If you wish to use a different name for the instance variable, you need to direct the compiler to synthesize the variable using the following syntax in your implementation:
@implementation YourClass |
@synthesize propertyName = instanceVariableName; |
... |
@end |
For example:
@synthesize firstName = ivar_firstName; |
In this case, the property will still be called firstName, and be accessible through firstName and setFirstName: accessor methods or dot syntax, but it will be backed by an instance variable called ivar_firstName.
Important: If you use @synthesize without specifying an instance variable name, like this:
@synthesize firstName; |
the instance variable will bear the same name as the property.
In this example, the instance variable will also be called firstName, without an underscore.
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//apple_ref/doc/uid/TP40011210-CH5-SW2
You Can Customize Synthesized Instance Variable Names @property的更多相关文章
- difference between instance variable and property
@interface MyClass : NSObject { NSString *name; NSArray *items; Something *something; IBOutlet NSTex ...
- non-ARC代码转 ARC 排除 “Existing instance variable 'delegate' for property with assign attribute must be _unsafe _unretained” 错误
原来非ARC代码是 @interface MHWebImageDownloader : NSObject { id<MHWebImageDownloaderDelegate> delega ...
- Swift开发教程--关于Existing instance variable '_delegate'...的解决的方法
xcode编译提示问题:Existing instance variable '_delegate' for property 'delegate' with assign attribute mu ...
- 警告"Local declaration of 'XXX' hides instance variable"原因
Local declaration of 'XXX' hides instance variable 是因为本地变量名跟函数变量名同名 ,.在命名上要注意.....
- Local declaration of 'XXX' hides instance variable
今天调试程序遇到这么一个警告! Local declaration of 'XXX' hides instance variable 遇到这种原因,是因为本地变量跟函数参数变量同名.改变其一即可.
- Summary: Class Variable vs. Instance Variable && Class Method
这里列举的是一些我平时碰到的一些Java Grammar,日积月累. Class Variable vs Instance Variable: Instance variables Instance ...
- Instance Variable Hiding in Java
class Test { // Instance variable or member variable private int value = 10; void method() { // This ...
- IOS Intro - Property Synthesis
http://www.thecodecrate.com/ios/objective-c/objective-c-property-synthesize/ 01. atomic ...
- 李洪强iOS经典面试题上
李洪强iOS经典面试题上 1. 风格纠错题 修改完的代码: 修改方法有很多种,现给出一种做示例: // .h文件 // http://weibo.com/luohanchenyilong/ / ...
随机推荐
- 在电脑上部署网站lls 浏览器上访问
在win7 上安装,首先是要进入lls中进行设置,这是第一种方法: 通过图形化的操作方式进行设置, 这个界面中的东西都比较重要,电脑出现问题的话一般在这都可以进行调整,程序和功能可以用来管理你安装的软 ...
- Marshmallow详解
目录 Marshmallow详解 1. Scheme 2. Serializing(序列化) 3. 过滤输出 4. Deserializing(反序列化) 5. 处理多个对象的集合 6. Valida ...
- Docker 安装 Redis, 搭建 Redis 环境
欢迎关注个人微信公众号: 小哈学Java, 文末分享阿里 P8 资深架构师吐血总结的 <Java 核心知识整理&面试.pdf>资源链接!! 个人网站: https://www.ex ...
- Linux图形界面从登录列表中隐藏用户和开机自动登录
从GDM-GNOME显示管理器:“ GNOME显示管理器(GDM)是一个管理图形显示服务器并处理图形用户登录的程序.” 显示管理器为X Window System和Wayland用户提供图形登录提示. ...
- sql server 根据字段去重
使用 row_number() over (partition by 要去重的字段 order by 排序字段) 数据库表结构 学生成绩表 UserGrade Id int ...
- Java NIO , AIO
New IO: 特点:不再阻塞 Channel , Buffer Async IO: 特点:异步
- Beyond Compare 4 30天评估期结束的解决办法
修改注册表 regedit注册表中删除项目:HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare 4\CacheId 删除dll 重命名 ...
- Android编译系统中的Android.bp
https://www.cnblogs.com/bluestorm/p/10895005.html Android.bp,是用来替换Android.mk的配置文件. 它使用Blueprint框架来解析 ...
- selenium.获取浏览器大小、设置浏览器位置、最大化浏览器
此篇博客学习控制浏览器的api,分别有: get_window_size() 获取浏览器大小 set_window_size() 设置浏览器位置 get_window_position() 获取浏览器 ...
- PostgreSQL 基本数据类型及常用SQL 函数操作
数据类型 名字 别名 描述 bigint int8 有符号的8字节整数 bigserial serial8 自动增长的8字节整数 bit [ (n) ] 定长位串 bit varying [ (n ...