SCTableViewController

@interface SCTableViewController
    : UITableViewController <UISplitViewControllerDelegate,
                             UIPopoverControllerDelegate>

This class functions as a means to simplify development with SCTableViewModel.

SCTableViewController conveniently provides several ready made navigation bar types based on SCNavigationBarType, provided that it is a subview of a navigation controller. SCTableViewController also defines placeholders for a tableView and a tableViewModel that the user can allocate and assign. If a tableViewModel is defined, SCTableViewController also connects its doneButton (if present) to tableViewModel’s commitButton automatically.

In addition, SCTableViewController fully manages memory warnings and makes sure the assigned table view is released once a memory warning occurs and reloaded once the view controller is loaded once more.

Finally, SCTableViewController provides several useful actions (SCTableViewControllerActions) that notify the delegate object of events like the view appearing or disappearing.

Configuration

  • Contains a valid SCTableViewModel that is associated with tableView and ready to use. If this model is replaced by a custom one, the class will automatically take care of associating it with tableView.

    Declaration

    Objective-C

    @property (nonatomic, strong) SCTableViewModel *tableViewModel;
  • The type of the navigation bar.

    Declaration

    Objective-C

    @property (nonatomic) SCNavigationBarType navigationBarType;
  • The navigation bar’s Add button. Only contains a value if the button exists on the bar.

    Declaration

    Objective-C

    @property (nonatomic, readonly) UIBarButtonItem *addButton;
  • The editButtonItem of ‘SCTableViewController’‘s superclass.

    Declaration

    Objective-C

    @property (nonatomic, readonly) UIBarButtonItem *editButton;
  • The navigation bar’s Cancel button. Only contains a value if the button exists on the bar.

    Declaration

    Objective-C

    @property (nonatomic, readonly) UIBarButtonItem *cancelButton;
  • Set to TRUE to allow the cancel button to appear when entering editing mode. Default: TRUE. @note: Only applicable if navigationBarType == SCNavigationBarTypeEditRight.

    Declaration

    Objective-C

    @property (nonatomic) BOOL allowEditingModeCancelButton;
  • The navigation bar’s Done button. Only contains a value if the button exists on the bar.

    Declaration

    Objective-C

    @property (nonatomic, readonly) UIBarButtonItem *doneButton;
  • When set to YES, the view controller will automatically disable all navigation bar buttons until its view fully appears. This setting is inhereted by all automatically generated detail view controllers. Default: NO.

    Declaration

    Objective-C

    @property (nonatomic) BOOL autoDisableNavigationButtonsUntilViewAppears;
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong) UIPopoverController *popoverController
  • The set of view controller action blocks.

    Declaration

    Objective-C

    @property (nonatomic, readonly) SCTableViewControllerActions *actions;
  • The current state of the view controller.

    Declaration

    Objective-C

    @property (nonatomic, readonly) SCViewControllerState state;

Managing Button Events

  • Property is TRUE if the view controller have been dismissed due to the user tapping the Cancel button. This property is useful if you do not with to subclass this view controller. See also SCTableViewControllerDelegate to get notified when the view controller is dismissed.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL cancelButtonTapped;
  • Property is TRUE if the view controller have been dismissed due to the user tapping the Done button. This property is useful if you do not with to subclass this view controller. See also SCTableViewControllerDelegate to get notified when the view controller is dismissed.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL doneButtonTapped;

Interface Builder Related

  • Method returns the Interface Builder data definition with the given name.

    Declaration

    Objective-C

    - (SCDataDefinition *)dataDefinitionWithIBName:(NSString *)ibName;

    Parameters

    ibName

    The name of the data definition. This name is typically found in IB’s document outline pane.

    Return Value

    The data definition.

  • This method should be implemented by SCTableViewController subclasses that wish to provide data source object to an SCObjectSection that has been created in Interface Builder.

    Note

    There is no need to implement this method for sections with data definitions of type SCUserDefaultsDefinition or SCiCloudKeyValueDefinition.

    Declaration

    Objective-C

    - (NSObject *)objectForSection:(SCObjectSection *)objectSection
                           atIndex:(NSUInteger)index;

    Parameters

    objectSection

    The object section that needs the data source object.

    index

    The object section index.

    Return Value

    An object compatible with objectSection’s data definition.

  • This method should be implemented by SCTableViewController subclasses that wish to provide data source objects to an SCArrayOfObjectsSection that has been created in Interface Builder. The method is typically called by the STV framework for sections with data definitions of type SCClassDefinition or SCDictionaryDefinition.

    Note

    There is no need to implement this method for sections with data definitions of type SCEntityDefinition or SCWebServiceDefinition.

    Declaration

    Objective-C

    - (NSMutableArray *)objectsForSection:(SCArrayOfObjectsSection *)objectsSection
                                  atIndex:(NSUInteger)index;

    Parameters

    objectsSection

    The objects section that needs the data source objects.

    index

    The objects section index.

    Return Value

    A mutable array of objects compatible with objectsSection’s data definition.

Managing Delegate

  • The object that acts as the delegate of ‘SCTableViewController’. The object must adopt the SCTableViewControllerDelegate protocol.

    Declaration

    Objective-C

    @property (nonatomic, weak) id delegate;

Internal Properties & Methods (should only be used by the framework or when subclassing)

  • ///////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////

    Declaration

    Objective-C

    @property (nonatomic, retain, readonly) NSArray *_STV_ibDataDefinitions;
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL ibEmbedded
  • Returns TRUE if the view controller currently has been given focus by its master model.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL hasFocus;
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL staticContentAddedToModel
  • Undocumented

    Declaration

    Objective-C

    - (void)invalidateStaticContent;
  • Method used internally to add all static content added in IB to the table view model.

    Declaration

    Objective-C

    - (void)addStaticContentToModel;
  • Method should be overridden by subclasses to perform any required initialization.

    Warning

    Subclasses must call [super performInitialization] from within the method’s implementation.

    Declaration

    Objective-C

    - (void)performInitialization;
  • Method gets called when the Cancel button is tapped. If what you want is to get notified when the Cancel button gets tapped without subclassing ‘SCTableViewController’, consider using SCTableViewControllerDelegate.

    Declaration

    Objective-C

    - (void)cancelButtonAction;
  • Method gets called when the Done button is tapped. If what you want is to get notified when the Cancel button gets tapped without subclassing ‘SCTableViewController’, consider using SCTableViewControllerDelegate.

    Declaration

    Objective-C

    - (void)doneButtonAction;
  • Method gets called when the Edit button is tapped.

    Declaration

    Objective-C

    - (void)editButtonAction;
  • Method gets called when the Cancel button is tapped while the table view is in editing mode.

    Declaration

    Objective-C

    - (void)editingModeCancelButtonAction;
  • Dismisses the view controller with the specified values for cancel and done.

    Declaration

    Objective-C

    - (void)dismissWithCancelValue:(BOOL)cancelValue doneValue:(BOOL)doneValue;
  • Called by master model to have the view controller gain focus.

    Declaration

    Objective-C

    - (void)gainFocus;
  • Called by master model to have the view controller lose focus.

    Declaration

    Objective-C

    - (void)loseFocus;