Macos 可可应用程序。(MAC)非常慢
我使用的是一个基于计时器的应用程序,我在主运行循环中连续运行3个计时器,这样在任何UI更新的情况下计时器都会连续运行。但大约1小时后,我的应用程序挂起,而不是按下按钮等。它至少需要10-15秒才能响应 我想知道MAC cocoa应用程序的滞后原因是什么。我正在开发一个基于计时器的应用程序。所以我需要多个计时器来运行。我也无效,当没有用的时候。但这仍然帮不了我 请指导mac的任何性能调试,以便我可以检查我的代码在哪里产生问题等 代码:Macos 可可应用程序。(MAC)非常慢,macos,cocoa,nstimer,nsviewcontroller,nstabview,Macos,Cocoa,Nstimer,Nsviewcontroller,Nstabview,我使用的是一个基于计时器的应用程序,我在主运行循环中连续运行3个计时器,这样在任何UI更新的情况下计时器都会连续运行。但大约1小时后,我的应用程序挂起,而不是按下按钮等。它至少需要10-15秒才能响应 我想知道MAC cocoa应用程序的滞后原因是什么。我正在开发一个基于计时器的应用程序。所以我需要多个计时器来运行。我也无效,当没有用的时候。但这仍然帮不了我 请指导mac的任何性能调试,以便我可以检查我的代码在哪里产生问题等 代码: 您的问题是nsrunlopCommonModes。使用sche
您的问题是nsrunlopCommonModes。使用scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:method,它将在NSDefaultRunLoopMode中调度NSTimer。如果UI正在更新,您的应用程序稍后将获得其他事件。请参阅post。NSRunLoop*runloop=[NSRunLoop currentlunloop];updateServerTimeTimer=[NSTimer Timer WithTimeInterval:1.0目标:自选择器:@selectorupdateServerTime用户信息:无重复:是];[runloop addTimer:updateServerTimeTimer forMode:NSRunLoopCommonModes];我认为你的问题在于使用公共模式。为什么要使用nsrunlopCommonModes?
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
updateServerTimeTimer = [NSTimer timerWithTimeInterval:1.0
target:self
selector:@selector(updateServerTime)
userInfo:nil
repeats:YES];
[runloop addTimer:updateServerTimeTimer forMode:NSRunLoopCommonModes];