Renaissance Outlets and Actions

Renaissance Outlets and Actions

Use XML elements and attributes in your .gsmarkup file to wire up outlets and actions between objects in the markup, and to the file’s owner.

Object references

Set the id attribute on an object element to give that object a unique identifier that you use when you reference it in outlets and actions. For example, if you define an NSImageView as <image id="profileImageView" editable="YES"/>, then you refer to it in an outlet or action as #profileImageView.

Refer to the file’s owner as #NSOwner. The file’s owner is the object you pass when you load the markup using -[NSBundle loadGSMarkupNamed:owner:].

Outlets

Connect outlets in a <connections/> block in your .gsmarkup file. The block contains any number of <outlet/> elements. Outlets have the following attributes:

  • source: The object that owns the connection. This is the object that has the outlet property you’re connecting.
  • target: The destination object for the connection. This is the object that you want to connect to the outlet.
  • key: The name of the outlet.

For example:

<connections>
	<outlet source="#NSOwner" target="#window" key="window"/>
</connections>

Actions

Connect an action to a receiver using the target attribute on the object that has the action. Use the action attribute to set the selector that it invokes on the receiver when the action occurs; include a colon in the action name if the action method has a parameter. For example:

<image id="imageView" editable="yes" target="#NSOwner" action="imageDropped:"/>