Skip to content

协议可以添加属性吗?如果可以怎么添加。 #35

@tbfungeek

Description

@tbfungeek
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@protocol TestProtocol <NSObject>
@property(nonatomic, strong , readwrite) NSString *name;
@end

NS_ASSUME_NONNULL_END
#import <Foundation/Foundation.h>

//protocal
#import "TestProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface TestObject : NSObject<TestProtocol>

@end

NS_ASSUME_NONNULL_END
#import "TestObject.h"

@implementation TestObject

@synthesize name = _name;

- (void)setName:(NSString *)name {
    _name = name;
}

- (NSString *)name {
    return _name;
}

@end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions