Skip to content

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

Open
@tbfungeek

Description

#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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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