在iOS12中间歇性地插入NSObject的cancelPreviousPerformRequestsWithTarget导致“无类的元类”错误

时间:2018-08-20 08:46:23

标签: ios iphone ocmock ios12

-(void)testNSObjectCancelPreviousPerformRequestsExpectationMock
     {
       XCTestExpectation *cancelExpectation = [self expectationWithDescription:@"cancel callback"];
       id objectMock = OCMClassMock([NSObject class]);
       [[[objectMock stub] andDo:^(NSInvocation *invocation)
       {
          NSLog(@"Reached!");
         [cancelExpectation fulfill];
        }] cancelPreviousPerformRequestsWithTarget:self
 selector:@selector(startWriteSettingsLogFileOperationForAccountId:)
 object:nil];

   [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(startWriteSettingsLogFileOperationForAccountId:) object:nil];
   [self waitForExpectationsWithTimeout:10 handler:nil];
}

如上述测试用例所示,对NSObject的cancelPreviousPerformRequestsWithTarget进行存根时,会间歇性地导致“无类的元类”错误。

0 个答案:

没有答案