To run the example project, clone the repo, and run pod install
from the Example directory first.
- Swift 4.2
SharePoster is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SharePoster'
- 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)]
...
}
sihon321, sihon321@gmail.com
SharePoster is available under the MIT license. See the LICENSE file for more info.