0:00:00Welcome to Under the Radar, a show about independent iOS app development. I'm Marco Arment.
0:00:06And I'm David Smith. Under the Radar is never longer than 30 minutes, so let's get started.
0:00:11So today we wanted to dive into everybody's favorite pastime as a developer, and that is debugging.
0:00:20It is a topic that I think we probably... it's kind of weird in some ways, because I think I probably spend
0:00:27at least half, if not a majority of my time in development debugging code that I write.
0:00:33Yet, in most of my actual formal preparation for being a software engineer, there was very, very little time and attention spent on it.
0:00:42Almost all of my classes and things were all focused on the actual development and the architecture side of things,
0:00:49whereas the reality is we spend most of our time fixing the problems and issues that arise in our apps.
0:00:55And these can range from all kinds of different levels. There's the while you're developing debugging process,
0:01:02where you write some code, you hit build and run, and you see if it works, and if it doesn't, you try and work out why.
0:01:10There's the more subtle, something happens every now and then, and you're not really sure why, and you try and track that down.
0:01:19And then there's the, you know, you're getting crash reports or bug reports from customers in the field, and then you have to try and track those down,
0:01:26which is even more exciting and challenging.
0:01:30But in all of them, I think there's an element of, you know, debugging is essentially, you have... you sort of identify that there's some problem,
0:01:40you then try and reproduce that problem in a way that you can then observe that problem,
0:01:47then you try and isolate where in the actual program that is happening, and then you can try and fix it.
0:01:54And you kind of go through this cycle of, you identify it, you reproduce it, you isolate it, and then you can fix it.
0:02:02And you kind of cycle through that, or at least that's the process that I tend to take,
0:02:05because if I don't go through each of those steps, I find that it's very hard to actually make progress.
0:02:10You know, if you can't... you know, some bugs really are, by their nature, kind of hard to reproduce.
0:02:15And if that's the case, like, you know, it's still a bug and it's still problematic,
0:02:19but if I get a bug report that I can't reproduce in any way, it's just as the same in some ways as not having that bug report in the first place,
0:02:27because I can't do anything with that information if I can't reproduce it.
0:02:31So, you know, my first step is always, let's reproduce this, and then, you know, try and find the part of code.
0:02:37And I think, having been a professional developer for enough years now, I feel like I have a better sort of sense for where the bugs might be hiding.
0:02:46You know, it's like, I've seen every, you know, not every bug, but I've seen a lot of bugs before,
0:02:52and you kind of get this sense of like, "Huh, this looks like this is an off-by-one error.
0:02:59This looks like this is a cache invalidation error. This looks like I'm writing something incorrectly here,
0:03:05or I forgot a case in a switch statement." Like, you kind of get this feeling for it, and then you can kind of go running around trying to find it.
0:03:12And then, of course, there's also, I guess, the other kind of debugging, which is even super fun,
0:03:16which is where there's a bug in the OS that you, you know, where your code is all doing the right thing,
0:03:23but then you're getting weird results, you know, from the OS.
0:03:27And so, that's an even more fun line of debugging where you kind of get this sense of, at a certain,
0:03:32you know, you keep going down and farther and farther down the rabbit hole until eventually you're like,
0:03:36hit a brick wall at the end of it, and you're like, "All right, well, I guess I file a bug."
0:03:40Yeah, and that's, you know, it's often easy for us to jump to, "Well, this must be a bug in the OS,"
0:03:49or my favorite one, "This must be a bug in the compiler," or something like that, when we can't figure it out.
0:03:54That is, for the vast majority of bugs that we face as programmers, that is almost never the case.
0:04:01It, like, first of all, you are unlikely to ever have a bug in the compiler actually affect you,
0:04:06and, you know, as you go up the stack of, you know, things that you're relying on, like, the OS does have bugs.
0:04:13Libraries that you're using will have bugs, but if you run into something in your app that seems like a bug,
0:04:21and you're tempted to blame the OS or a library or something like that,
0:04:25really make sure that you can't figure out that it's your bug first, because chances are very, very good.
0:04:32It's probably your bug. The vast majority of the time of those cases, it will really be your bug.
0:04:38It's only a question of whether you can find it, but don't just say, "Oh, well, it's a bug in the OS.
0:04:43I guess I gotta just deal with this," or move on or yell at them.
0:04:46Really make sure it's not your bug first, because, again, the odds are strongly in favor of it being yours.
0:04:52Yeah, because the reality is, like, most of our time, at least in my experience, dealing with bugs,
0:05:00it's almost always something I forgot to do or a case that I forgot to consider when I was originally doing it.
0:05:07Not necessarily out of laziness, even. Sometimes it's that. Sometimes you have the always classic,
0:05:14like, you know, you see an example where it's like, if error doesn't equal nil, then do something with it.
0:05:21And then if you don't actually do anything, when eventually you do run into the situation where the error is not nil,
0:05:26then all of a sudden things break, and there's that kind of laziness.
0:05:29But more often, it's just like you forgot to do something, and then it comes back to bite you.
0:05:34And I feel like the--I think there was a--maybe there was an XKCD cartoon about this,
0:05:42where it's sort of the stages of debugging, where you go from, like, it's like,
0:05:46oh, you get a bug report, and you're like, oh, no, that can't be right. I'm sure my code is good.
0:05:51And then you're kind of like, oh, no, it's actually broken. And then you go to the, like, how did this ever work phase?
0:05:57You're like, how on earth did this even work? Because it's amazing how, when you look back at your own code,
0:06:03you know, this is the code that you wrote with your own hands on a keyboard.
0:06:07You put this into Xcode. You come back and look at it, and you're like, how on earth? What am I doing?
0:06:13And I feel like that is the hardest part, or why debugging is so hard, is you have to recreate all of this sort of state
0:06:23and information that went into the creation of the code, hold that in your mind,
0:06:27and then run it through a scenario that's happening, and to then see why it's doing something weird.
0:06:33And very often, I find, like, the hardest thing is to try and understand even what the code is trying to do in the first place,
0:06:39or why there's this weird exception that was introduced there years or decades ago,
0:06:46and you're like, huh, I wonder why I did that. I don't know anymore. And that makes debugging really, really hard.
0:06:53- Yeah, and this is, it's also a major argument for keeping things simple and not that clever in the first place.
0:07:01As we talked about, I think, a while ago now, I try to avoid overly clever code styles,
0:07:08things like using really dense short hands or really clever mechanics, things like generics in Swift, that kind of thing.
0:07:19You kind of use overly clever complex language features or constructs where it looks really cool,
0:07:27and you feel really smart when you do it, but when you have to come back and debug code in six months,
0:07:33and you have totally forgotten what led you to write that, and you've forgotten the cleverness behind it,
0:07:39and you have to figure it out by looking at it or figuring it out by its effects,
0:07:44it's often very, very hard to do that. And you often, as a programmer, you might eventually hear the wisdom of,
0:07:52like, write code for someone else to read, but really what you should be doing is writing code for yourself in three weeks to read,
0:08:01because you will have probably forgotten by then why you did what you did.
0:08:05So if you keep things simple from the beginning and not be too overly clever with the way you write things
0:08:11and make things straightforward to read and to kind of self-document, then you will be doing yourself a huge favor.
0:08:19Documentation, separate documentation, can help with some of these things, but I've found in practice that,
0:08:26maybe it's just me, I don't document things that well. I try to just write things that are obvious when you look at them,
0:08:32and that just have good names and straightforward approaches, and that tends to work very well.
0:08:38That can never be out of date, because it's the code itself.
0:08:41And then for minimizing bugs to begin with, I think it's, again, very important not to be too clever and to realize,
0:08:51you know, for me, many of my bugs come from quick workarounds or quick hacks that I do when I encounter some other bug.
0:09:00And so one great example of this that I'm sure many iOS programmers face is,
0:09:06whenever you are doing something in, like, a launch loop or in a UI, you know, response loop or something,
0:09:15and there's some weird behavior that, or some weird precondition that you can't quite accommodate in a straightforward way.
0:09:23So you just dispatch async to the next run loop of the main queue, and you say,
0:09:28"All right, dispatch async onto main queue, do this thing on the next run."
0:09:32And that's a really nice, quick way to avoid a lot of, like, you know, weird complexity or obvious bugs as you're developing.
0:09:42But I have found in almost every case that using a dispatch async is almost always a bad idea,
0:09:50like when you're just, like, deferring work till later on the main queue or something.
0:09:54Like, obviously there are uses where it's fine, but, like, if that's your approach to solve a problem,
0:09:59then you get into concurrency bugs and weird conditions there that are really hard to fix and diagnose and reproduce.
0:10:10And, again, it's like one of those areas where it seems like a clever thing when you're writing it,
0:10:18and in the case of, like, bug avoidance, like, it seems like, "Oh, this will be a quick fix for this weird little bug.
0:10:23I'll just wrap it in dispatch async and that will fix the problem."
0:10:28But then you introduce all these weird other problems that might be non-obvious, and those become very hard to debug.
0:10:36So, in addition to keeping code simple as you write it, for the purposes of debugging,
0:10:42I also would strongly recommend avoiding concurrency if you can and avoiding playing with threads and queues
0:10:50when not necessary or when not warranted.
0:10:54Yeah, because I feel like what you're doing there, I mean, and I'm very guilty of that.
0:10:57Like, there have, I have done the, you know, dispatch async fix probably a hundred times,
0:11:03two hundred times in my career, like, all the time.
0:11:06And I cannot overstate how many bugs that I've had to fix end up being a poorly used dispatch async.
0:11:14Yeah, because I think the reality is what you're doing, and this is maybe a maturity thing,
0:11:19but it's the understanding that, like, when I do that now, I understand that I'm not fixing the problem.
0:11:25I'm changing the bug from whatever it is, say I have a bug that happens, you know,
0:11:30one out of every hundred times the app runs.
0:11:33And, you know, that's a problem, you know, one percent of users are hitting this issue.
0:11:36I wrap it in dispatch async. What I'm doing is not removing that problem.
0:11:41What I'm doing is changing it into a, like, one in ten thousand bug, which is better,
0:11:46but also incredibly difficult now to actually, like, properly fix and diagnose and reproduce, etc., etc.
0:11:54Like, it is the kind of fix where it isn't actually solving it. It's just making it less likely.
0:11:59Which sometimes, you know, pragmatically, I've, you know, I'm sure there are many places in, you know,
0:12:03my shipping apps where I have that, and it's just one of, it's like a conscious choice that you're just like,
0:12:07"Well, the actual fix is too hard or would require a massive refactoring or some kind of, you know,
0:12:13thing where you can make this trade-off in choice."
0:12:16And you say, you know, like, "I'm just going to fix this by patching it."
0:12:19And I know that what I'm doing is going to cause a problem for me down the road.
0:12:22I know that, you know, there is, this bug is, hasn't magically disappeared as a result of this,
0:12:27but, like, it's a conscious choice. And that's a balance.
0:12:31But, yeah, ultimately, you know, most, when you're writing the code, you're kind of trying to do your future self a favor,
0:12:36as much as you can. Because I think one of the things that I struggle with, too, when I'm writing code
0:12:41is the realization that all of these things that seem obvious to me when I'm writing the code,
0:12:47because I'm in a mindset where I'm focused entirely on whatever the solving this problem is.
0:12:52Like, there's all these things that just seem obvious. Like, of course, you know, like, this is the way this works,
0:12:56you know, that's why this is set up this way, this value will, you know, will always transform from this to this.
0:13:01Like, there's all these things that seem obvious. And then, in the future, they're entirely non-obvious.
0:13:07And the thing, the biggest difficulty I have with things like documentation
0:13:12is that it's kind of impossible to know what your future self is going to want to know,
0:13:19because everything seems obvious and kind of trivial in the present.
0:13:26And so, like, I think I'm kind of like, I tend to only document code in my apps that,
0:13:32where I'm doing something that is clearly weird or like, strange, you know,
0:13:37where you have some kind of magic number that you have to introduce into something,
0:13:41where it's like, I know, why am I multiplying this value by 1.632?
0:13:46There's a reason for that, and if there is, like, you know, that's the kind of thing that you write down.
0:13:50But otherwise, you end up with, like, writing your program twice if you're, you know, overly documenting it.
0:13:54So, as much as when I'm debugging, I kind of wish my past self had written all this stuff down,
0:14:00the reality is my past self wouldn't actually know what I need to know right now,
0:14:04because if they did, they could have just written, you know, made the code more obvious or clear in the first place, probably.
0:14:10Or at least that's what I tell myself.
0:14:13We respond to this week by Pingdom.
0:14:16Start monitoring your websites and servers today at pingdom.com/radar.
0:14:21You got a 14-day free trial, and when you use code RADAR at checkout, you got 20% off your first invoice.
0:14:26Pingdom is a wonderful monitoring service.
0:14:30They are focused on making the web faster and more reliable for everyone who has a site,
0:14:35because they offer powerful, easy-to-use monitoring tools and services.
0:14:39So, if you're a Pingdom user, you can monitor the availability and performance of your servers,
0:14:43your databases, or your website, and it's so easy to do.
0:14:47They test for more than 70 global test servers, and they can emulate visits to your site as often as every minute.
0:14:54And they can do cool things like cookies and logins and everything else, too.
0:14:57Because, you know, these days, websites are becoming more and more sophisticated,
0:15:00and very often include multiple different parts with several different dependencies.
0:15:04Maybe you depend on an external service, or maybe only the login screen does this one thing in your code.
0:15:09And you need to check all these things, and you can do all that with Pingdom, and loads more in addition to that, too.
0:15:15They can make it possible to monitor the availability of all these key interactions people have with your site.
0:15:20Because, you know, a lot of times it's more complex than your site is up or your site is down.
0:15:25So, stuff breaks on the internet all the time. Pingdom knows this.
0:15:29They detect around 13 million outages a month.
0:15:32So, regardless of whether you have a small website or you're managing a whole infrastructure,
0:15:36it is very important to monitor the availability and performance.
0:15:39And Pingdom, when it goes down, they alert you in any way you want.
0:15:44You can have text messages, you can have push notifications, emails.
0:15:47It's so configurable. We've even used it in the past to monitor other people's websites.
0:15:52Like, David and I have both independently used it to monitor the WWDC page for changes.
0:15:58Like, in the past, when it was really important to know when WWDC tickets went on sale.
0:16:01I've used Pingdom for a very long time. Highly recommended.
0:16:04Check it out today and you will be the first to know when your site is down or being too slow.
0:16:10So, go to Pingdom.com/Radar for a 14-day free trial and use code radar to get 20% off your first invoice.
0:16:18Thank you very much to Pingdom for their support of this show and Relay FM.
0:16:21So, the other thing that's probably worth diving into a little bit, too, is the way in which we actually do debugging.
0:16:29Because maybe it's a shocking revelation, but I am, I believe, what is technically called a caveman debugger.
0:16:38The printf debugging?
0:16:40I do all of my debugging using, you know, nslog and the console, which I think is often disparagingly referred to as caveman debugging, which is fine.
0:16:51I'm sure there are better ways to do that.
0:16:53I mean, every now and then I'll go to a WWDC session where they're talking about all the crazy things you can do in Xcode, where you can set conditional breakpoints and all this kind of really clever stuff.
0:17:04And in the end, what I always do is just, I end up just nslogging tons of data to the console.
0:17:11Because it's one of those things where most of what debugging is trying to do is, it's like you're trying to unwind the state machine that is your app.
0:17:20Where you're trying to work out, it's like, your app is in this problem, you're in a good state, then something happens and you're in a bad state.
0:17:27Like that is, you know, at a very high level, that is what a bug is.
0:17:30And what you're trying to do is identify that, you know, at what point it's going from that good state to that bad state.
0:17:37Like what is happening there?
0:17:39I mean, I've been professionally developing for 17 years now or something.
0:17:44And I still, like, the most effective and powerful tool is just nslogs everywhere.
0:17:49And you get kind of good at it.
0:17:52Like, I can identify and find things fairly quickly this way because you kind of get the sense of, you know,
0:17:57A, you're trying to isolate where in the code it's happening.
0:18:00And so you'll end up putting nslogs, you know, in different parts of your app that you think might be part of it
0:18:06and trying to work out which code is getting hit when you do it.
0:18:11And then something that I also find really helpful is when I format my nslogs as tab-delimited text.
0:18:21So like often I'll have several variables that I'm trying to observe and watch.
0:18:25And I nslog those as a tab-delimited set of strings because then I can take the output from the console
0:18:33and I can copy-paste that into Excel and it'll put it into columns for me.
0:18:37That's interesting.
0:18:39And you can take that data and then look at it over multiple runs.
0:18:44It's a way to actually make it into something that's useful.
0:18:48At least for me, in the way that my mind works, that's how I debug the best.
0:18:53I'm taking something out of the console, looking at it, often in Excel, and then kind of finding the pattern,
0:19:00finding the thing, and then I can actually go and fix it.
0:19:03And I don't know if that works for me.
0:19:07And sometimes I feel bad about it.
0:19:11I feel like they have all these really powerful and clever tools.
0:19:13But the reality is, I think the hardest part too is that so much of debugging is...
0:19:20The hardest part is often the reproduction part.
0:19:23And getting everything, it's hard to observe these issues sometimes.
0:19:28And so the nice thing about a console log is that you can have those running without being attached to the debug server, for example.
0:19:36You can create these situations where these things happen.
0:19:41Sometimes it gets really awkward to have your app attached to the debugger.
0:19:46Because sometimes when it is attached to the debugger, the bug goes away.
0:19:50There's lots of weird situations and issues where NSLog debugging is the best.
0:19:56But I'm very aware that by doing it that way, I'm not taking advantage of more sophisticated tools.
0:20:02But I know for myself that's what works.
0:20:05There's lots of different kinds of bugs.
0:20:09And a lot of these different methods are more or less suitable to different ones.
0:20:13For example, NSLog debugging, which I do a lot myself, is not necessarily the best option if you have a nitty-gritty code level bug.
0:20:26This function isn't always returning the right value.
0:20:28For that, I prefer to use conditional breakpoints.
0:20:30So I can see whenever this value is something out of whack, stop here and then I will inspect the stuff around it.
0:20:35But NSLog debugging is a lot more helpful for things like larger systems interacting with each other,
0:20:43any kind of large operations, concurrency, things where you're not really sure where the bugs might be,
0:20:50but you just want to get a good idea of what is going on in the system.
0:20:54NSLog debugging is also very, very helpful in situations in which the debugger itself is impractically slow to do things.
0:21:04So a lot of Swift context, this is the case from what I've heard.
0:21:07It's also very much the case when you're debugging on device on the watch.
0:21:12Because then the round trip between your computer running Xcode and the phone and the slow watch hardware,
0:21:19trying to break watch apps with breakpoints and inspect local variables around and running things in the debugger command line,
0:21:27is so slow when doing things on the watch that sometimes it's better off to just do something,
0:21:32do it a different way, do printout debugging or whatever else.
0:21:36For me, I also debug very differently if I'm looking at a crash report versus some kind of behavior in the app that I'm catching live.
0:21:45It's very important to look in iTunes Connect and to look at the, or rather I guess now it's in the organizer in Xcode,
0:21:54to look at the crash report that Apple's getting for you.
0:21:57Look at what's being gathered there.
0:22:00There's a whole lot of different problems that your app can have in the wild.
0:22:04And the fact that we can get our crash reports basically all the time from Apple,
0:22:10that whenever an app crashes we get notified about that, that's pretty awesome.
0:22:14There's of course also lots of different other services as well,
0:22:17but there are some types of crashes that only Apple's crash logs will generally, reliably be able to report to you.
0:22:24That includes things like if iOS kills your app for some reason that isn't necessarily a crash,
0:22:30but if your app is getting killed in the background or something, or if your extensions are getting killed,
0:22:34then that's things that iOS can provide very useful feedback to if you look for it.
0:22:40And that's all in the Xcode organizer.
0:22:42And one of the things I can recommend highly is look at those,
0:22:46and a lot of times the organizer won't tell you, like if you get like,
0:22:49I was just spending a lot of time debugging crashes in my today widget, or my widget I guess,
0:22:54and if you look at just the crash log it's not very helpful in the organizer.
0:23:00But if you right click and show in finder on that crash and you dive into the bundle
0:23:05and you can get the raw crash logs that are inside of that bundle,
0:23:08when you look at the raw logs you can get a termination code.
0:23:11And a lot of times that is springboard telling you something.
0:23:14And there's a great technical note, TN-2151, Understanding and Analyzing Application Crash Reports.
0:23:21And this tells you all the crazy codes that your app might be killed with.
0:23:25So one of the things that I was facing is my extension was accessing the SQLite database
0:23:32in the shared app group container.
0:23:34I don't recommend doing this now, but now I know better.
0:23:37But if you're accessing an SQLite database in a shared container in an extension,
0:23:42at the time that the OS suspends you, it will kill your app with a certain code that says deadlock in hex.
0:23:48And if you didn't look at this document, and if you didn't find that crash report and find that code,
0:23:54and if you didn't then look at this document to see what that means,
0:23:57and it tells you right here, it's been terminated by the OS because it held onto a file lock
0:24:01or SQLite database during suspension.
0:24:03And before I found all this out, I just didn't know why my extension just kept crashing for everybody.
0:24:11And people kept reporting things like, "Hey, your app is crashing in the background for some reason.
0:24:14I'm getting all these logs on my phone. What's going on?"
0:24:16iOS tells you these things. It's telling you useful information here.
0:24:19And so if you look at those crash logs in the Xcode organizer,
0:24:24and if you look up what these different termination codes mean, you'll probably find out something useful.
0:24:30And this is all like, and we have wonderful things like,
0:24:34if you're kind of wondering whether you fixed a rare crash or not,
0:24:38you can look at the analytics section of iTunes Connect, and it will graph for you
0:24:42how many crashes per day your app is having.
0:24:45And it marks on the graph where your updates occur.
0:24:49So you can say, "Oh look, when this update was released, the crashes dropped by half.
0:24:55So the thing I think I fixed, I probably did fix."
0:25:00There's all sorts of useful things you can get from crash logs and things like that.
0:25:04And one of the reasons why I do also, as I said earlier, kind of recommend against unnecessary use of dispatch async
0:25:12is because that makes your crash logs less useful to you.
0:25:15Because usually the crash logs will not report where the block was dispatched from.
0:25:22Some of the more advanced ones, like hockey, try to do this, and they have mixed degrees of success in my experience.
0:25:28And so if your code is simpler, then any crash log you get will also be more useful to you.
0:25:35Yeah, and I think crash logs are definitely a great source for so much of this stuff.
0:25:41And I feel like, in general, I will say that Xcode, as much as I don't use all of its tools,
0:25:46some of the stuff that you're talking about, of going into the organizer, there's some really useful tools that we have at our disposal
0:25:56to be tracking a lot of this stuff down now, which I don't think we had before.
0:25:59It makes me think even of one of the other tools that I use a lot in debugging, in a strange way, is version control.
0:26:07And specifically, get blame is often incredibly helpful in trying to track down weird situations in my apps,
0:26:18where code is doing something weird, and I'm trying to work out why I structured it in the way I structured it.
0:26:23And this is something that I love in Xcode, where you can go into the top right, where you go into the source control thing,
0:26:29and you can do blame, and it will show you all of, for every line of code in your app,
0:26:35it will show you which commit that line of code was introduced into your app with.
0:26:39And so you often will end up happening there. By using that view, I can see, "Huh, that's weird.
0:26:45Here's this one random line of code that is left over from an old version, that everything else was updated."
0:26:51Or situations like that, and Xcode is really, and then you can, if you double click on it, it will show you that commit,
0:26:58and it will show you the relevant, how that file changed with that commit.
0:27:04And that's another example of one of these little tools in Xcode where it's like, it helps you understand what's going on,
0:27:10in the same way that, yeah, that's a really great one.
0:27:13I mean, I love in the crash logs where it can help you, take you right to where the crash happened,
0:27:18rather than sitting there and trying to work out which, you know, if this crash happened in this file on this line number,
0:27:27like, well, that's useful, but it's also way more useful to just take me to that line number.
0:27:32So there's definitely some great tools in Xcode that I think make a lot of debugging a lot simpler, and that I'm very grateful for.
0:27:38I would also say, when you're running your app and you're trying to figure out maybe what's going on with the bug,
0:27:43always watch that pane in Xcode that shows you the running CPU usage and memory of the app.
0:27:50And of course, you can go into instruments and get, you know, like a more fine-grained version of this.
0:27:53But like, yesterday, there was this really tricky bug that I could not figure out.
0:27:57Like, the app just started behaving really weirdly when loading episodes of a certain podcast, and it, like, really weirdly.
0:28:03And it would eventually disconnect from Xcode. It was a massive, massive weird bug.
0:28:07And Springboard would crash.
0:28:09And what led me to the solution was that I was, I happened to be glancing at that pane that was showing me the resource graphs in Xcode during one of the runs,
0:28:18and I noticed that right before it crashed, memory usage skyrocketed all the way up to, like, a gig, and then everything freaked out and blew up.
0:28:26And so then I was able to say, "Hey, wait a minute. That's unusual. That stands out.
0:28:31Let me run it under the allocations instrument run that can show you where all your memory is being used."
0:28:38And I did that and figured out what the bug was within, like, a half hour after that.
0:28:44This is a bug that's been bothering me for weeks. I couldn't figure it out.
0:28:47And then within a half hour of noticing, "Hey, this thing is out of the ordinary on the memory meter here," I had to fix.
0:28:52So, like, you know, use the tools that are available to you when appropriate, or just use nslog and printf debugging everywhere.
0:29:01Yeah. And, I mean, the love of what you hit on there, though, is one thing that I will say that I love about debugging is that so often you get to the end,
0:29:08and there's, like, a relatively straightforward solution that fixes the problem, and, like, that is one of the greatest joys of being a software development.
0:29:16When you, like, you see the problem, you see the solution, and you can implement it, and, like, it's gone.
0:29:22And this thing that was problematic and hurting your users is now just completely vanished.
0:29:27And, like, that's, like, a great victory, and I always love when that happens.
0:29:30It doesn't always happen, but when it does, it's absolutely awesome. So it's the one reason I love debugging.
0:29:35That's why we do all this, right? That feeling when it finally works. We're like, "Yes! I love that feeling."
0:29:40Yes.
0:29:41All right. Thanks, everybody, for listening this week, and we'll talk to you next week.
0:29:44Bye.