• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Tracking down problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tracking down problems


  • Subject: Tracking down problems
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 25 Sep 2014 12:08:18 +1000

I don't want to pick on Brian, but when I see someone say they wasted many hours, and then a day or so later see them say the same thing, I have to ask why. I know some of this stuff is difficult, and I know documentation is often problematic, but it seems to me that what's lacking is a systematic approach to problem-solving. Too often, people go into trial-and-error flailing mode, and end up confused, tired, angry, and none the wiser.

So FWIW, this is my rough guide to how to approach a bit of code that isn't working. Yes, a lot of it is obvious -- but then, so are most errors.

* Use NSLog() statments to try to track down exactly where things go wrong.

* If the offending statement uses nested method calls, un-nest them so there is only one method call per statement. You want to narrow the problem down as much as possible.

* When you find the single offending statement, read it for sense -- several times. Are you calling methods on the right things? Are the variables spelled correctly? Are you coercing willy-nilly in hope?

* Look in the Console for any error messages.

* Assuming the statment has a method call, look up the method in the docs. Double-check its spelling and case; copying and pasting can help. Double-check the underscores or colons, and that there are a matching number of parameters. Double-check that it's an instance/class method, depending on how you are calling it. Double-check that the instance or class is presented properly. Double-check the types of the parameters and the return type. Double-check that you haven't mis-typed the parameter variables. Double-check that you have used reference properly for any out parameters. Double-check that you have added the framework for the relevant class to your project. Double-check that the method does what you want.

* Don't rely on your memory.

* Do the previous checking step again. This will catch most problems.

* If that doesn't work, search my book for anything relevant.

* If you have Explorer, extract enough code to run there, and see what appears in the log. Try using the same method there, with known good parameters. If there's a similar method, try it to see if you have the parameters right.

* In the documentation for the relevant class, click near the top where it says More related items.... If it points to a related programming guide, look at it -- it will probably include sample Objective-C code and tips.

* Search the Web: enter "Cocoa <name of the method>". You might find sample Objective-C code that will give you a clue.

* If you're still stuck, try to write a bit of stand-alone code that demonstrates the problem. You'd be amazed at how often this leads to a solution.

* Post the shortest possible commented standalone code, asking for help. Don't expect list members to have to guess what variables contain what, or what you're trying to do.


--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Requesting even <more> assistance with terminology, please (an update)
  • Next by Date: Re: Requesting even <more> assistance with terminology, please (an update)
  • Previous by thread: Re: Requesting even <more> assistance with terminology, please (an update)
  • Next by thread: Still cannot get CF terminology correct
  • Index(es):
    • Date
    • Thread