Xcode调试器跨越通过forwardInvocation执行的方法

时间:2015-07-30 16:52:32

标签: ios xcode ocmock

我在使用OCMock时注意到以下行为,并且在探索之后我发现Xcode调试器如何处理未实现的方法是一个问题。这是一个例子:

@implementation ForwardingClass

- (id)init {
    self = [super init];
    self.delegate = [[DelegateClass alloc] init];
    return self;
}

- (void)forwardInvocation:(NSInvocation *)anInvocation {
    [anInvocation invokeWithTarget:self.delegate];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
    return [self.delegate methodSignatureForSelector:sel];
}

- (BOOL)respondsToSelector:(SEL)aSelector {
    return YES;
}

@end



@implementation DelegateClass

- (void)forwardedMethod {
    NSLog(@"got it!");
}

@end

现在我们可以称之为:

ForwardingClass *forwardingClass = [[ForwardingClass alloc] init];

// Xcode will not step into this method
[(id)forwardingClass forwardedMethod];

Xcode不会进入forwardedMethod。更糟糕的是,如果我在forwardInvocation中设置断点,它就不会在那里打破。实际效果是你无法进入任何被OCMock部分嘲笑的对象。

任何想法如何解决这个问题?

是Xcode中的错误(或意外的“功能”)吗? 我在Xcode 6和Xcode 7 beta 4上都试过这个。

0 个答案:

没有答案