0

I'm building an iOS app, and I noticed something odd - sometimes, the line of code

let someVariable = UIApplication.shared.applicationIconBadgeNumber

is extremely laggy (taking on the order of seconds to complete), and sometimes it is not. Is there a reason for the variation in times this line of code takes to complete? It seems like a simple assignment, so I'm a bit confused about why it would take so long.

rma
  • 1,853
  • 1
  • 22
  • 42

1 Answers1

0

If you care about performance of your app, then you can't measure it with debugger attached and in Debug configuration, since it has additional overhead.
Instead try new Signpost with Instruments article

If you care only in duration while debugging, then I could guess it affected by communication with Springboard process + debugger protection. But I would say it mean nothing in general.

ManWithBear
  • 2,787
  • 15
  • 27
  • The performance of the app isn’t materially impacted by the debugger in this case. I checked using a timer and it’s on the order of ~4 seconds for this single code to execute. I’m just confused why this would take so long to work considering it’s only getting the value of a variable – rma Mar 24 '19 at 04:55
  • @JohnDoe please provide more information how you measure it with timer? Do you mean time profiler? Or have you tried proposed by me `os_signpost`? – ManWithBear Mar 24 '19 at 11:34