SCViewController

@interface SCViewController : UIViewController <UISplitViewControllerDelegate,
                                                UIPopoverControllerDelegate> {
  UITableView *_tableView;
}

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

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

In addition, SCViewController 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, SCViewController provides several useful actions (SCViewControllerActions) and delegate methods (SCViewControllerDelegate) that notify the delegate object of events like the view appearing or disappearing.

Note

You do NOT have to use ‘SCViewController’ in order to be able to use SCTableViewModel, but it’s highly recommended that you do so whenever you need a UIViewController.

Configuration

  • Set this outlet to the table view that will be associated with tableViewModel. Once a valid table view is set, it will automatically be associated with tableViewModel.

    Note

    If the table view is added programmatically, then the user must also add it to the view controller’s view.

    Declaration

    Objective-C

    @property (nonatomic, strong) UITableView *tableView;
  • 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 SCViewController’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;
  • Undocumented

    Declaration

    Objective-C

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) SCViewControllerActions *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 SCViewControllerDelegate 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 SCViewControllerDelegate to get notified when the view controller is dismissed.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL doneButtonTapped;

Managing Contained View Controller

  • This property is automatically set to the contained child view controller, allowing the view controller to act as a proxy for this child. When acting as a proxy, both the view controller’s tableView and tableViewModel will return the child’s instead of its own.

    Note

    If your view controller has more than once contained view controller child, you may manually assign this property to the child of your choice.

    Declaration

    Objective-C

    @property (nonatomic, weak) SCTableViewController *containedViewController;

Managing Delegate

  • The object that acts as the delegate of ‘SCViewController’. The object must adopt the SCViewControllerDelegate protocol.

    Declaration

    Objective-C

    @property (nonatomic, weak) id delegate;

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

  • Returns TRUE if the view controller currently has been given focus by its master model.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL hasFocus;
  • 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 ‘SCViewController’, consider using SCViewControllerDelegate.

    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 ‘SCViewController’, consider using SCViewControllerDelegate.

    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;