SharePoster 0.6.0

SharePoster 0.6.0

Maintained by sihon321.



  • By
  • sihon321

SharePoster

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 4.2

Installation

SharePoster is available through CocoaPods. To install it, simply add the following line to your Podfile:

 pod 'SharePoster'

Usage

  • An example implementation of didSelectPost
- (void)didSelectPost {
    // Perform the post operation.
    // When the operation is complete (probably asynchronously), the Share extension should notify the success or failure, as well as the items that were actually shared.
 
    NSExtensionItem *inputItem = self.extensionContext.inputItems.firstObject;
 
    NSExtensionItem *outputItem = [inputItem copy];
    outputItem.attributedContentText = [[NSAttributedString alloc] initWithString:self.contentText attributes:nil];
    // Complete this implementation by setting the appropriate value on the output item.
 
    NSArray *outputItems = @[outputItem];
 
    [self.extensionContext completeRequestReturningItems:outputItems expirationHandler:nil completion:nil];
// Or call [super didSelectPost] to use the superclass's default completion behavior.
}
  • SharePoster
override func viewDidLoad() {
  sharePoster = SharePoster(extensionContext?.inputItems)
  
  sharePoster.loadData {
      defer {
        DispatchQueue.main.async {
          self.collectionView.reloadData()
        }
      }

      self.images = sharePoster.contentsItem.getContents()
  }
}

ContentsItem.swift

public struct ContentsItem {
  
  var contents: [URL]
  
  var documents: [String]
  
  var urls: [(url: URL, title: String)]
  
  ...
  
}

Author

sihon321, [email protected]

License

SharePoster is available under the MIT license. See the LICENSE file for more info.