@interface Author1 : NSObject
{
@
public
NSString *_isName;
NSString *name;
NSString *isName;
NSString *_name;
}
- (
void
)setName;
- (
void
)_setName;
- (
void
)setIsName;
- (NSString *)getName;
- (NSString *)name;
- (NSString *)isName;
- (NSString *)_name;
@end
@implementation Author1
+(
BOOL
)accessInstanceVariablesDirectly{
return
NO;}
- (
void
)setName:(NSString*)name{ NSLog(@
"1,设置值的优先函数 %s - %@"
,__func__,name); }
- (
void
)_setName:(NSString *)name{ NSLog(@
"2,设置值的优先函数 %s - %@"
,__func__,name); }
- (
void
)setIsName:(NSString *)name{ NSLog(@
"3,设置值的优先函数 %s - %@"
,__func__,name); }
- (NSString *)getName{
return
NSStringFromSelector(_cmd);}
- (NSString *)name{
return
NSStringFromSelector(_cmd);}
- (NSString *)isName{
return
NSStringFromSelector(_cmd);}
- (NSString *)_name{
return
NSStringFromSelector(_cmd);}
@end
UIAlertAction *two = [UIAlertAction actionWithTitle:@
"setKey,getKey方式设置&获取"
style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
Author1* author1 = [Author1
new
];
[author1 setValue:@
"author1 的新名字"
forKey:@
"name"
];
NSString* name = [author1 valueForKey:@
"name"
];
NSLog(@
"取值的优先函数 value for key : %@"
,name);
NSLog(@
"取值_name:%@"
,author1->_name);
NSLog(@
"取值_isName:%@"
,author1->_isName);
NSLog(@
"取值name:%@"
,author1->name);
NSLog(@
"取值isName:%@"
,author1->isName);
}];