我们可以在Objective-C块中使用inout参数吗?
像这样的我们可以在Objective-C块中使用inout参数吗?,objective-c,objective-c-blocks,swizzling,Objective C,Objective C Blocks,Swizzling,像这样的 ^void (__unsafe_unretained UIViewController self, UIScrollView *scrollView, CGPoint velocity, inout CGPoint *targetContentOffset){ // Something } 或者使用这些参数的替代方案是什么 背景: 我正在尝试使用UIScrollviewDelegate的ScrollViewWillendDraging:withVelocity:targetC
^void (__unsafe_unretained UIViewController self, UIScrollView *scrollView, CGPoint velocity, inout CGPoint *targetContentOffset){
// Something
}
或者使用这些参数的替代方案是什么
背景:
我正在尝试使用UIScrollviewDelegate
的ScrollViewWillendDraging:withVelocity:targetContentOffset:
方法来滑动滚动视图,但最后一个参数targetContentOffset
是一个inout参数。我正在使用swizzle实例,它期望一个块被用作替换方法
我正在尝试使用的代码
[scrollViewDelegateObj swizzleMethod:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:) withReplacement:^id(JG_IMP original, __unsafe_unretained Class swizzledClass, SEL selector) {
return JGMethodReplacement(void, UIViewController *, UIScrollView *scrollView, CGPoint velocity, CGPoint *targetContentOffset){
JGOriginalImplementation(void, scrollView, velocity, targetContentOffset);
};
}];
有人能帮我吗?是的,你可以:Cocoa的集合类有枚举方法,使用这样的参数来获取块。你的代码不工作吗?不,我得到一个编译时错误,那是什么错误?未知类型名称“inout”:(如果删除单词
inout
,会发生什么情况?