zoukankan      html  css  js  c++  java
  • error: synthesized property 'name' must either be named the same as a compatible instance variable or must explicitly name an instance variable问题解决

    #import <Foundation/Foundation.h>
    
    @interface Person : NSObject{
        NSString * _name;
        NSUInteger _age;
    }
    
    @property (nonatomic, copy) NSString* name;
    @property (nonatomic, assign) NSUInteger age;
    
    @end
    @implementation Person
    
    @synthesize name = _name;
    @synthesize age = _age;
    
    @end

    正确实现如上述代码,之前参照Object-C程序设计 (第4版)写的实例,就是报:

    error: synthesized property 'name' must either be named the same as a compatible instance variable or must explicitly name an  instance variable错误。

    参考书中改代码如下:

    #import <Foundation/Foundation.h>
    
    @interface Person : NSObject
    
    @property (nonatomic, copy) NSString* name;
    @property (nonatomic, assign) NSUInteger age;
    
    @end
  • 相关阅读:
    03.yaml语法和playbook写法
    02.ansible的常用模块
    01.ansible基本配置与使用
    24.删除表名
    23.MySQL的备份与恢复
    22.更改表名
    MySQL的表操作
    MySQL的库操作
    MySQL的用户管理
    数据库及MySQL概述
  • 原文地址:https://www.cnblogs.com/yanwei-wang/p/8676100.html
Copyright © 2011-2022 走看看