   (^:export perform-action-for-row-at-index-path-with-sender [this sel section row sender]))
 
 (defprotocol TableViewDataSource
+  "Defines a protocol consistent with `UITableViewDataSource`."
 
   (^:export TableViewDataSource-implements [this])
 

            [clojure.data :as data])
  (:require-macros [goby.macros :refer [reify]]))

(def env (atom {}))

(def table-view-scroll-positions {:table-view-scroll-position-none   0
                                  :table-view-scroll-position-top    1
                                  :table-view-scroll-position-middle 2
                                  :table-view-scroll-position-bottom 3})

(def table-view-scroll-positions' (set/map-invert table-view-scroll-positions))

(def table-view-row-animations {:table-view-row-animation-fade      0
                                :table-view-row-animation-right     1
                                :table-view-row-animation-left      2
                                :table-view-row-animation-top       3
                                :table-view-row-animation-bottom    4
                                :table-view-row-animation-none      5
                                :table-view-row-animation-middle    6
                                :table-view-row-animation-automatic 100})

(def table-view-row-animations' (set/map-invert table-view-row-animations))

(def table-view-cell-accessory-types {:table-view-cell-accessory-none                     0
                                      :table-view-cell-accessory-disclosure-indicator     1
                                      :table-view-cell-accessory-detail-disclosure-button 2
                                      :table-view-cell-accessory-checkmark                3
                                      :table-view-cell-accessory-detail-button            4})

(def table-view-cell-accessory-types' (set/map-invert table-view-cell-accessory-types))

(def table-view-cell-editing-styles {:table-view-cell-editing-style-none   0
                                     :table-view-cell-editing-style-delete 1
                                     :table-view-cell-editing-style-insert 2})

(def table-view-cell-editing-styles' (set/map-invert table-view-cell-editing-styles))

(def device-orientations {:device-orientation-unknown              0
                          :device-orientation-portrait             1
                          :device-orientation-portrait-upside-down 2
                          :device-orientation-landscape-left       3
                          :device-orientation-landscape-right      4
                          :device-orientation-face-up              5
                          :device-orientation-face-down            6})

(def device-orientations' (set/map-invert device-orientations))

(def interface-orientations {:interface-orientation-portrait             (:device-orientation-portrait device-orientations)
                             :interface-orientation-portrait-upside-down (:device-orientation-portrait-upside-down device-orientations)
                             :interface-orientation-landscape-left       (:device-orientation-landscape-left device-orientations)
                             :interface-orientation-landscape-right      (:device-orientation-landscape-right device-orientations)})

(def interface-orientations' (set/map-invert interface-orientations))

(def ^:private ui-control-events {:touch-down              (bit-shift-left 1 0)
                                  :touch-down-repeat       (bit-shift-left 1 1)
                                  :touch-drag-inside       (bit-shift-left 1 2)
                                  :touch-drag-outside      (bit-shift-left 1 3)
                                  :touch-drag-enter        (bit-shift-left 1 4)
                                  :touch-drag-exit         (bit-shift-left 1 5)
                                  :touch-up-inside         (bit-shift-left 1 6)
                                  :touch-up-outside        (bit-shift-left 1 7)
                                  :touch-cancel            (bit-shift-left 1 8)
                                  :value-changed           (bit-shift-left 1 12)
                                  :editing-did-begin       (bit-shift-left 1 16)
                                  :editing-changed         (bit-shift-left 1 17)
                                  :editing-did-end         (bit-shift-left 1 18)
                                  :editing-did-end-on-exit (bit-shift-left 1 19)})

(def ^:private inverted-ui-control-events (set/map-invert ui-control-events))

(def ^:private attributes {:not-applicable 0
                           :enabled        1
                           :text           2
                           :selected       3
                           :highlighted    4
                           :hidden         5})

(def ^:private inverted-attributes (set/map-invert attributes))

(defn- form-events-mask
  [ui-control-events-set]
  (reduce bit-or 0 (map ui-control-events ui-control-events-set)))

(def fetched-results-change-type {:fetched-results-change-insert 1
                                  :fetched-results-change-delete 2
                                  :fetched-results-change-move   3
                                  :fetched-results-change-update 4})

(def fetched-results-change-type' (set/map-invert fetched-results-change-type))

(defprotocol TableViewDelegate

  ;; All methods in this protocol are optional


  (^:export did-change-content [this])
  (^:export section-index-title-for-section-name [this section-name]))

(defn user-interface-idiom-ipad?
  "Returns true iff the interface idiom is iPad."
  []
  (= "iPad" (:user-interface-idiom @env)))

(defn reify-fetched-results-controller-delegate
  "Provides a refication of `FetchedResultsControllerDelegate` that maniuplates a table-view."
  [table-view]
  (reify FetchedResultsControllerDelegate

    (did-change-object-at-index-path-for-change-type-new-index-path
