1
typedef
void
(
^
aBlcok)(NSString
*
a,CGPointpt);
2
3 @interfaceTs : NSObject {
4
5 aBlcokblk;
6
7 }
8
9 @property(copy) aBlcok blk;
10
11 - ( void )Call:(NSString * )str AtPoint:(CGPoint)pt;
12
13 @end
2
3 @interfaceTs : NSObject {
4
5 aBlcokblk;
6
7 }
8
9 @property(copy) aBlcok blk;
10
11 - ( void )Call:(NSString * )str AtPoint:(CGPoint)pt;
12
13 @end
在Ts.m中:
1
@implementation Ts
2
3 @synthesize blk;
4
5 - ( void )Call:(NSString * )str AtPoint:(CGPoint)pt
6
7 {
8
9 if (blk)
10
11 blk(str, pt);
12
13 }
14
15 @end
2
3 @synthesize blk;
4
5 - ( void )Call:(NSString * )str AtPoint:(CGPoint)pt
6
7 {
8
9 if (blk)
10
11 blk(str, pt);
12
13 }
14
15 @end
使用Ts:
1
Ts
*
t
=
[[Ts alloc]init];
2
3 t.blk = ^ (NSString * str,CGPointpt) {
4
5 NSLog( @" %@ %@ " , str,NSStringFromCGPoint(pt));
6
7 };
8
9 [tCall: @" ABCD " AtPoint:CGPointMake( 101 , 102 )];
2
3 t.blk = ^ (NSString * str,CGPointpt) {
4
5 NSLog( @" %@ %@ " , str,NSStringFromCGPoint(pt));
6
7 };
8
9 [tCall: @" ABCD " AtPoint:CGPointMake( 101 , 102 )];
最后输出结果:ABCD {101, 102}