title: How can we use uiactivity class method - (void) performActivity in UIViewController class?
body: <p>I'm building an article reading app for iPhone. I am stuck in some issues.I'm facing a problem in social sharing. I have tried couple of approaches.
  First Approach</p>
  
  <p>We are using Facebook sdk to share the article link,title and image. Ideally, when we click on Facebook activity item in uiactivityviewcontroller, my Facebook sdk code should run but I am unable to do so.</p>
  
  <p>Second approach</p>
  
  <p>We tried for custom activity item in uiactivityviewcontroller and were successful in making a custom icon and give action to that which is a default method of class uiactivity(- (void) performActivity), but I want to use this method in my view controller class where we pass article link,title and image by segue.</p>
  
  <p>here is my code:</p>
  
  <pre><code>           #import "ysAPActivityIcon.h"
             #import &lt;Social/Social.h&gt;
             #import &lt;FacebookSDK/FacebookSDK.h&gt;
             @implementation ysAPActivityIcon
  
              - (NSString *)activityType { return @"it.albertopasca.myApp"; }
              - (NSString *)activityTitle { return @"Open Maps"; }
               - (UIImage *) _activityImage { return [UIImage imageNamed:@"iPad_jobs.png"];           }
               - (BOOL) canPerformWithActivityItems:(NSArray *)activityItems { return YES; }
               - (void) prepareWithActivityItems:(NSArray *)activityItems { }
                - (UIViewController *) activityViewController { return nil; }
                - (void) performActivity {
                           }
            // my view controller class:
              #import "ysAPActivityProvider.h"
              #import "ysAPActivityIcon.h"
                #import "ysDetailViewController.h"
               @interface ysDetailViewController() &lt;UIWebViewDelegate,UIActivityItemSource&gt;
             - (void) performActivity {
  
             FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
           params.link = [NSURL URLWithString:@"https://www.youtube.com/watch?v=pa8lsBNG31c"];
          //    // If the Facebook app is installed and we can present the share dialog
           if ([FBDialogs canPresentShareDialogWithParams:params]) {
  
            // Present share dialog
            [FBDialogs presentShareDialogWithLink:params.link
                                 handler:^(FBAppCall *call, NSDictionary *results,    NSError *error) {
                                    if(error) {
                                        // An error occurred, we need to handle the error
                                         // See: https://developers.facebook.com/docs/ios/errors
                                        NSLog(@"Error publishing story: %@", error.description);
                                    } else {
                                        // Success
                                        NSLog(@"result %@", results);
                                    }
                                }];
  
  // If the Facebook app is NOT installed and we can't present the share dialog
              } else {
         // FALLBACK: publish just a link using the Feed dialog
  
  // Put together the dialog parameters
         NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 @"YourStory", @"name",
  
                                 nil];
  
  // Show the feed dialog
             [FBWebDialogs presentFeedDialogModallyWithSession:nil
                                         parameters:params
                                            handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                                if (error) {
                                                    // An error occurred, we need to handle the error
                                                    // See:  https://developers.facebook.com/docs/ios/errors
                                                    NSLog(@"Error publishing story: %@", error.description);
                                                } else {
                                                    if (result ==   FBWebDialogResultDialogNotCompleted) {
                                                        // User canceled.
                                                        NSLog(@"User cancelled.");
                                                    } else {
                                                        // Handle the publish feed callback
                                                        //   NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
  
                                                        //  if (![urlParams valueForKey:@"post_id"]) {
                                                        // User canceled.
                                                        NSLog(@"User cancelled.");
  
                                                        //    } else {
                                                        // User clicked the Share button
                                                        //         NSString *result =      [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                        //        NSLog(@"result %@", result);
                                                    }
                                                }
  
                                            }];
  
             }
  
  
  
        }
  </code></pre>