Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecific expression in if condition causes 7 second delay in execution
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/6274642/unhiding-a-view-is-very-slow-in-ctcallcenter-calleventhandler">Unhiding a view is very slow in CTCallCenter callEventHandler</a> </p> </blockquote> <p>I've been stuck on a problem for two days. <a href="https://stackoverflow.com/questions/6274642/unhiding-a-view-is-very-slow">I asked on SO yesterday</a>, but so far haven't been able to find a solution. I thought I'd repost and try to be more specific since I have more experience with the issue.</p> <p>In my app delegate (didFinishLaunching), I set up a callEventHandler on CTCallCenter. The idea is that when a callState changes, I post a notification with a userInfo dict containing the call.callState. In my view, I observe this notification, and when the userInfo dict contains a value of CTCallDisconnected, I want to unhide a view.</p> <p>The problem I'm having is that the unhiding aspect is taking, almost consistenly, ~ 7 seconds. Everything else is working fine, and I know this because I NSLog before and after the unhiding, and those logs appear immediately, but the darned view still lags for 7 seconds.</p> <p>Here's my code:</p> <p>appDidFinishLaunching:</p> <pre> self.callCenter = [[CTCallCenter alloc] init]; self.callCenter.callEventHandler = ^(CTCall* call) { // anounce that we've had a state change in our call center NSDictionary *dict = [NSDictionary dictionaryWithObject:call.callState forKey:@"callState"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"CTCallStateDidChange" object:self userInfo:dict]; }; </pre> <p>I then listen for this notification when a user taps a button that dials a phone number:</p> <pre> [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ctCallStateDidChange:) name:@"CTCallStateDidChange" object:nil]; </pre> <p>Then, in ctCallStateDidChange:</p> <pre> - (void)ctCallStateDidChange:(NSDictionary *)userInfo {NSLog(@"121"); if ([[userInfo valueForKey:@"userInfo"] valueForKey:@"callState"] == CTCallStateDisconnected) { NSLog(@"before show"); ((SavedToCallLogView *)[self.view viewWithTag:kNONEMERGENCYCALLSAVEDTOLOG_TAG]).hidden = false; NSLog(@"after show"); } </pre> <p>I've tracked the problem down to the if condition in the above code sample:</p> <pre> if ([[userInfo valueForKey:@"userInfo"] valueForKey:@"callState"] == CTCallStateDisconnected) { </pre> <p>If I simply replace that with:</p> <pre> if (1 == 1) { </pre> <p>Then the view appears immediately!</p> <p>The thing is, those NSLog statements are logging immediately, but the view is lagging in it's unhiding. How could that condition cause only part of it's block to execute immediately, and the rest to wait ~ 7 seconds?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload