Skip to content

is unset

by admin on March 12th, 2017
if the mainStack is unset then
  -- show "please open a document" window.
end if

if [ABAddressBook sharedAddressBook] is unset then
  -- the user rejected the "may this application access the address book" prompt.
end if

Use this operator to detect whether a variable is unset. Unset variables behave just like they contained an empty string, but are used in some cases where you may want to distinguish between receiving an empty string or nothing.

For example, when you call a function foo() that does not have a return statement, foo() is unset will return “true”, while if the function has a “return empty” statement, foo() is unset will return “false”.

Unset values are also used with native Objective-C calls. E.g. if you call [ABAddressBook sharedAddressBook] and that returns NIL, you can use the is unset operator to detect that the function returned a NIL object.

From → Syntax Elements

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS