0

I've written a small application for OS X in AppleScriptObj-C containing a UItextfield. Everything works fine except that when user has entered text and erased it, the textfield becomes nil. How can I check if it's nil with AppleScriptObj-C?

  • Checking for "length of textfield is equal to 0" throws "Can’t get length of missing value."
  • Checking for "textfield doesn't contains string" works for nil textfield, but then textfield with text in it throws "Can’t make «class ocid» id «data optr0000000090CB250000600000» into type list, record or text."

Any ideas how to solve this?

Thanks, Patrik

patej
  • 1
  • Solved this by first coercing the textfield to text "set textfield to textfield as text" and then checking "if nimi is equal to "missing value" then...". So quite simple in the end, I just got confused with the mix of obj-c objects and applescript variables. – patej Oct 05 '14 at 10:17

1 Answers1

0

to compare a string value from a textfield to an Applescript string you need to convert it to an Applescript string before:

if textfield's stringValue as string = "" then ...

Greetings, Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18