多个类的情况处理

我们建立一个类,叫SepecialView

SepecialView.h


@interface SepecialView : UIView

@property (nonatomic,assign)NSInteger integer;

@property (nonatomic,strong)UIImageView *imageView;

@property (nonatomic,strong)UIImageView *headView;

@end


@interface Person : NSObject

@property (nonatomic,copy)NSString *name;

@property (nonatomic,copy)NSString *gender;

@property (nonatomic,copy)NSString *age;

@end


SepecialView.m

@implementation SepecialView

@end


@implementation Person

@end


当我们导入这个类SepecailView时,我们相当于导入了两个类,我们既可以实例化SepecailView,也可以实例化Person.


    SepecialView *sepecialView = [[SepecialView alloc]init];

    sepecialView.integer =1000;

    NSLog(@"sepecialView======%d",sepecialView.integer);

    Person *person = [[Person alloc]init];

    person.name =@"*****";

    person.gender =@"";

    person.age =@"21";

    NSLog(@"打印person的名字%@==性别===%@ 年龄=== %@",person.name,person.gender,person.age);


但是要注意,我们这么写时,一定不能忽略

@implementation Person

@end


这个实现的代码,否则就会报错。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值