xcode - Objective C general troubleshooting process -
i'm 2 weeks learning objective-c (but previous experience java , python), , after initial hurdle i'm starting hang of things pointers, arc, , delegates. however, on more 1 occasion i've come across problem/bug have no thought how solve, , worse, have no thought how approach solution.
my general troubleshooting strategy, when things aren't working expected, follows:
reread through relevant section of code create sure general logic , flow makes sense look @ self-defined methods , create sure they're working properly put few nslog statements within code see doing unexpected things once i've identified troublesome part(s), search apple docs/stackoverflow/google see if has experienced same problems.
i might omitting step , general process works part. however, there problems come across process not work, , totally stuck. few examples:
i trying load nswindowcontroller using proper method called in proper location, wasn't displaying. turned out issue pointers, after long time of aimless experimenting i'm testing illustration pulled straight apple technical q&a create clickable hyperlink nsattributedstring, when hover on said link pointing hand cursor not appear. see my thread more info. i've created nsbutton , want pointing hand cursor appear when hover on button. i'm using code in accepted reply here, doesn't work , don't know why. also, subclassing every button want utilize tedious , messy.
clearly troubleshooting strategy not working. 1 time exhaust 4 steps no avail, have seek random fixes until one, seemingly magically, works. neither time efficient nor helping me understand language better. there steps can add together troubleshooting strategy, , if so, they?
for example, when asked friend same question, suggested using breakpoints monitor instance variables , objects.
when across bug,
first thing need read error, see error , occurred. go specific location of error, see if there obvious mistake. if not, set break point @ skeptical location, step in , check step step see if each value on stack expected be. you may want set test, consider possibilities, such if value null, if it's 0, etc.
sometimes bugs tricky, not recommended read code on 1 time again each time see error.
objective-c xcode osx cocoa oop