-1

I want to share image,link through own app as activity type is used subclass UIActivity class and used this action method code

  NSString *message = [NSString stringWithFormat:@"%@\n",[self.dataModel artLook_Title]];
    UIImage *imageToShare =self.profileImageView.image; //[UIImage imageNamed:@"test.jpg"];
    if (self.tinyURL==nil) {
        [self initilizeTinyURL];
    }
     NSArray *items = @[message,[self tinyURL],imageToShare];//
    NSArray *activities = @[[self customActivity],UIActivityTypePostToFacebook,UIActivityTypePostToTwitter];
    UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:activities];
    [self presentViewController:controller animated:YES completion:nil];

I am crash at

[self presentViewController:controller animated:YES completion:nil];

Error:-[__NSCFConstantString _beforeActivity]: unrecognized selector sent to instance 0x38f2b6b8

Any help will appreciated.

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68

2 Answers2

1

The problem is this line:

NSArray *activities = @[[self customActivity],UIActivityTypePostToFacebook,UIActivityTypePostToTwitter];

You are passing in your own custom activity (good) and two string constants for standard activities (bad).

  1. You can't pass NSString where UIActivity is expected.
  2. Why are you specifying standard activities in the array where you are only supposed to provide your app-specific activities?

Change the line to:

NSArray *activities = @[[self customActivity]];

If your goal is to only show certain activities, use the excludedActivityTypes property to list the standard activities you don't want. This is where you use the standard UIActivityTypeXXX constants.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
1

this line is error

 NSArray *activities = @[[self customActivity],UIActivityTypePostToFacebook,UIActivityTypePostToTwitter];

-[__NSCFConstantString _beforeActivity]: unrecognized selector sent to instance 0x38f2b6b8 -- The error says you were passing the nil or String object in applicationActivities

the UIActivity expects a list of UIActivity objects

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143