Stinger is a high-efficiency library with great compatibility, for aop in Objective-C, using libffi instead of Objective-C message forwarding. It is 20+ times faster than the Aspects, from message-sending to Aspect-oriented code ends.
你好,看了是饿了么团队出品,我就用中文了。
项目中有较多地方使用Aspects,正在换 Stinger,遇到点问题,我有一个分类监听 UIScrollView contentSize 变化,使用 Stinger 无法正确工作,上代码:
crash at 'can't match a ffi_type of {CGSize=dd}'
你好,看了是饿了么团队出品,我就用中文了。 项目中有较多地方使用Aspects,正在换 Stinger,遇到点问题,我有一个分类监听 UIScrollView contentSize 变化,使用 Stinger 无法正确工作,上代码: crash at 'can't match a ffi_type of {CGSize=dd}'
`
import "UIScrollView+ContentSizeChangedHandler.h"
import <objc/runtime.h>
import <Stinger/Stinger.h>
static NSString *const kID = @"UIScrollView.setContentSize.after";
@interface UIScrollView () @property (nonatomic, assign) CGSize wj_contentSizeChangedHandler_oldContentSize; ///< 旧 contentSize @end
@implementation UIScrollView (ContentSizeChangedHandler)
(void)wj_setContentSizeChangedHandler:(ContentSizeChangedHandler)handler { void (^insideHandler)() = ^() { !handler ?: handler(self.contentSize); };
self.wj_contentSizeChangedHandler_oldContentSize = self.contentSize; [self st_hookInstanceMethod:@selector(setContentSize:) option:STOptionAfter usingIdentifier:kID withBlock:^(id params, CGSize contentSize) {
if (!CGSizeEqualToSize(self.contentSize, self.wj_contentSizeChangedHandler_oldContentSize)) {
// 设置新值
self.wj_contentSizeChangedHandler_oldContentSize = self.contentSize;
insideHandler();
}
}];
}
`
希望帮助解决,谢谢