SharePoster 0.6.0

SharePoster 0.6.0

sihon321维护。



  • 作者:
  • sihon321

SharePoster

CI Status Version License Platform

示例

要运行示例项目,请克隆存储库,并首先从Example目录运行pod install

要求

  • Swift 4.2

安装

SharePoster通过CocoaPods提供。要安装它,只需将以下行添加到Podfile中。

 pod 'SharePoster'

使用

  • 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)]
  
  ...
  
}

作者

sihon321, [email protected]

许可证

SharePoster遵从MIT许可证。更多信息请参阅LICENSE文件。