12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // ShareViewController.m
- // ShareSupport
- //
- // Created by HonorLee on 16/1/13.
- // Copyright © 2016年 HonorLee. All rights reserved.
- //
- #import "ShareViewController.h"
- #import <MobileCoreServices/MobileCoreServices.h>
- @interface ShareViewController ()
- @property NSUserDefaults *userDefaults;
- @end
- @implementation ShareViewController
- - (BOOL)isContentValid {
- // Do validation of contentText and/or NSExtensionContext attachments here
- return YES;
- }
- - (void)didSelectPost {
-
- // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
- _userDefaults = [[NSUserDefaults alloc]initWithSuiteName:@"group.honorlee.TumblrDownloader"];
- [_userDefaults synchronize];
- NSMutableArray *tmpData = [NSMutableArray arrayWithArray:(NSMutableArray *)[_userDefaults objectForKey:@"tasks"]];
- NSLog(@"%lu",(unsigned long)[tmpData count]);
- // NSArray *inputItems = self.extensionContext.inputItems;
- // NSLog(@"%lu",(unsigned long)[inputItems count]);
- NSExtensionItem *content = self.extensionContext.inputItems[0];
- NSItemProvider *itemProvider = content.attachments.firstObject;
- if([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeURL]){
- [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *url,NSError *err) {
- [tmpData addObject:url.absoluteString];
- [_userDefaults setObject:tmpData forKey:@"tasks"];
- [_userDefaults synchronize];
- }];
- }
-
- [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
- // NSString *type = (NSString *)
- // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
-
- }
- - (NSArray *)configurationItems {
- // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
- return @[];
- }
- @end
|