Skip to content

longpf/AspectsCocoa

Repository files navigation

AspectsCocoa

License MIT  CocoaPods Compatible  Support 

一个简单实现AOP的库

什么是AOP?

AOP: Aspect Oriented Programming 面向切面编程。

面向切面编程(也叫面向方面):Aspect Oriented Programming(AOP),是目前软件开发中的一个热点。利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可重用性,同时提高了开发的效率。   AOP是OOP的延续,是(Aspect Oriented Programming)的缩写,意思是面向切面(方面)编程。  

详细可以参看这里>>

如何使用?

添加 :


[self.label addObserver:self forSelector:@selector(setText:) withBlock:^(AOPObserverInfo *info,NSString *text){

        NSLog(@"text = %@",text);

}];
 
    
[self.label addObserver:self forSelector:@selector(drawTextInRect:) withBlock:^(AOPObserverInfo *info,NSValue *rectValue){
        
        NSLog(@"rectValue = %@",rectValue);
        
 }];

移除 :

[self.label removeObserver:self forSelector:@selector(setText:)];

or

[self.label removeObserver:self];

详细可以参看demo>>

安装

CocoaPods

pod 'AspectsCocoa'

手动

AspectsCocoa文件夹拖到项目中

实现原理

可以参看我的博客>>

其他

如果大家发现什么错误,建议可以联系我 QQ466142249