I'm 2 weeks into learning Objective-C (but previous experience with Java and Python), and after the initial hurdle I'm starting to get a hang of things like pointers, ARC, and delegates. However, on more than one occasion I've come across a problem/bug that I have no idea how to solve, and worse, I have no idea how to approach a solution.
My general troubleshooting strategy, for when things aren't working as expected, is as follows:
- Reread through the relevant section of my code to make sure the general logic and flow makes sense
- Look at any self-defined methods and make sure they're working properly
- Put a few NSLog statements within the code to see where it is doing unexpected things
- Once I've identified the troublesome part(s), search the apple docs/stackoverflow/google to see if anyone has experienced the same problems.
I might be omitting a step , but this general process works for the most part. However, there are some problems that I come across for which this process does not work, and I get totally stuck. A few examples:
- I was trying to load an NSWindowController using the proper method called in the proper location, but it wasn't displaying. Turned out to be an issue with pointers, after a long time of aimless experimenting
- I'm testing an example pulled directly from an Apple Technical Q&A to create a clickable hyperlink into an NSAttributedString, but when you hover over said link the pointing hand cursor does not appear. See my thread for more info.
- I've created an NSButton and want the pointing hand cursor to appear when I hover over the button. I'm using the code in the accepted answer here, but it doesn't work and I don't know why. Also, subclassing every button I want to use would be tedious and messy.
Clearly my troubleshooting strategy is not working. Once I exhaust all 4 steps to no avail, I have to just try random fixes until one, seemingly magically, works. This is neither time efficient nor good for helping me understand the language better. Are there steps that I can add to my troubleshooting strategy, and if so, what are they?
For example, when I asked a friend the same question, they suggested using breakpoints to monitor instance variables and objects.