@class ClassB;
@interface ClassA : NSObject
@property(nonatomic, readonly) ClassA *(^aaa)(BOOL enable);
@property(nonatomic, readonly) ClassA *(^bbb)(NSString* str);
@property(nonatomic, readonly) ClassB *(^ccc)(NSString* str);
@implement ClassA
- (ClassA *(^)(BOOL))aaa
{
return
^(BOOL enable) {
if
(enable) {
NSLog(@
"ClassA yes"
);
}
else
{
NSLog(@
"ClassA no"
);
}
return
self;
}
}
- (ClassA *(^)(NSString *))bbb
{
return
^(NSString *str)) {
NSLog(@
"%@"
, str);
return
self;
}
}
- (ClassB * (^)(NSString *))ccc
{
return
^(NSString *str) {
NSLog(@
"%@"
, str);
ClassB* b = [[ClassB alloc] initWithString:ccc];
return
b;
}
}
@interface ClassB : NSObject
@property(nonatomic, readonly) ClassB *(^ddd)(BOOL enable);
- (id)initWithString:(NSString *)str;
@implement ClassB
- (ClassB *(^)(BOOL))ddd
{
return
^(BOOL enable) {
if
(enable) {
NSLog(@
"ClassB yes"
);
}
else
{
NSLog(@
"ClassB no"
);
}
return
self;
}
}
id a = [ClassA
new
];
a.aaa(YES).bbb(@
"HelloWorld!"
).ccc(@
"Objective-C"
).ddd(NO)
请发表评论