NSObject

Undocumented

  • Posts a new notification originating from the receiver.

    canvas.addTapGestureRecognizer { location, state in
        self.canvas.post("tapped")
    }
    

    Declaration

    Swift

    public func post(event: String)

    Parameters

    event

    The notification name for the event

  • An action to run on receipt of a given event.

    canvas.on(event: "tapped") {
        println("received tap")
    }
    

    Declaration

    Swift

    public func on(event notificationName: String, run executionBlock: Void -> Void) -> AnyObject

    Parameters

    event

    The notification name to listen for

    run

    A block of code to run when the receiver hears the specified event name

    Return Value

    A token to use for cancelling the action.

  • Register an action to run when an event is triggered by the specified sender. Returns an observer handle you can use to cancel the action.

     canvas.on(event: "tapped", from: anObject) {
         print("obj was tapped")
     }
    

    Declaration

    Swift

    public func on(event notificationName: String, from sender: AnyObject?, run executionBlock: Void -> Void) -> AnyObject

    Parameters

    notificationName

    The notification name to listen for

    sender

    The object from which to listen for the notification

    executionBlock

    A block of code to run when the receiver hears the specified notification name

    Return Value

    A token to use for cancelling the action.

  • Cancels any actions registered to run for a specified object.

    canvas.cancel(self)
    

    Declaration

    Swift

    public func cancel(token: AnyObject)

    Parameters

    token

    A token returned from a call to on(event:run:) method