Follow

Upgrading version 2.0.2 to 2.1.0

The standard KGDocumentPicker is now deprecated. You should change your projects to use either the KGDocumentLinearPicker (visually identical to the KGDocumentPicker) or the new KGDocumentGridPicker as the deprecated picker is liable to be removed from subsequent versions of the framework.

The following changes are needed to switch to KGDocumentLinearPicker or KGDocumentGridPicker.

In DocumentPickerViewController.m, change the type of the first argument of documentPicker:didAddControlsForDocument:inView: to id<KGAbstractDocumentPicker>. The new method signature should be:

- (void)documentPicker:(id<KGAbstractDocumentPicker>)picker didAddControlsForDocument:(KGDocument *)document inView:(UIView *)view;

In DocumentPickerViewController.h, you must change the type of the docPicker property to match the class you select inDocumentPickerView-iPhone.xib and DocumentPickerView-iPad.xib (see below).

You must change the class of the doc picker in DocumentPickerView-iPhone.xib and DocumentPickerView-iPad.xib files. Select the doc picker in the interface and the change the class name to one of KGDocumentLinearPicker or KGDocumentGridPicker in the Identity Inspector.

Important note if you are using a downloadDelegateButton

If you have been using a downloadDelegateButton with the old KGDocumentPicker, you probably will have wired the button up to anIBAction method somewhat like the following one:

- (IBAction)primaryDocumentActionButtonPressed:(id)sender {
  StylistAppDelegate *appDelegate = (StylistAppDelegate*)[[UIApplication sharedApplication] delegate];
  switch ([self.documentPicker.selectedDocument state]) {
    case KGDocumentStateDownloaded:
      [appDelegate openDocument:self.currentDocument];
      break;
    case KGDocumentStateNew:
      [appDelegate downloadDocument:self.currentDocument];
      break;
    case KGDocumentStateUpdated:
      [appDelegate downloadDocument:self.currentDocument];
      break;
    default:
      break;
  }
}

The new KGDocumentLinearPicker correctly wires up the downloadDelegateButton to trigger the same behavior as the framework supplied download button i.e. triggering the download/update if online and new content available otherwise calling the target of the value changed control event on the picker provided a downloaded copy of the document exists. This means that one should probably remove the above method and the connection(s) to it from the delegateButton(s). At the very least the calls to open the document should be removed or else it will be opened twice, which could have adverse effects on the application's stability and functionality.

Note regarding KGDocumentGridPicker

If you choose to use the grid picker you will likely get compiler warnings like:

DocumentPickerViewController.m:57:14: warning: 'KGDocumentGridPicker' may not respond to 'setMostRecentDocumentFirst:'
  [docPicker setMostRecentDocumentFirst:NO];
   ~~~~~~~~~ ^
DocumentPickerViewController.m:60:14: warning: 'KGDocumentGridPicker' may not respond to 'setShouldSnap:'
  [docPicker setShouldSnap:YES];
   ~~~~~~~~~ ^
2 warnings generated.

These methods are specific to the linear picker and will cause the application to crash if you do not remove them (or at least comment them out).

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk