为什么当我使用方法respondsToSelector:
或instancesRespondToSelector:
在第 43 行时,我无法绕过 STAssertTrue?
//我的测试用例代码
- (void)testApiClass {
//Check object
NSString* classKey = @"Api";
id obj = NSClassFromString(classKey);
STAssertNotNil(obj, [NSString stringWithFormat:@"Model '%@' not found.", classKey]);
//Check properties
NSArray* properties =
@[
@"performSyncRequestWithUri::",
@"performAsyncRequestWithUri:::",
];
for (NSString* property in properties) {
SEL propertySel = NSSelectorFromString(property);
BOOL isRespondsToSel = [obj respondsToSelector:propertySel];
STAssertTrue(isRespondsToSel, [NSString stringWithFormat:@"Property '%@' not found on object of class name '%@'", property, [obj class]]);
}
}
@interface Api : NSObject
- (NSDictionary*)performSyncRequestWithUri:(NSString *)requestUri params:(NSDictionary *)params;
- (void)performAsyncRequestWithUri:(NSString *)requestUri params:(NSDictionary *)params completionHandler:(void (^)(NSDictionary *, NSError *))completionBlock;
@end