-1

Here is my code where I use to share an image vaia facebook:

NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
UIActivityViewController *activityVC = 
    [[UIActivityViewController alloc] initWithActivityItems:array 
                                      applicationActivities:nil]; 
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, 
                                     UIActivityTypePrint,
                                     UIActivityTypePostToTwitter,
                                     UIActivityTypePostToWeibo,
                                     UIActivityTypeMail,
                                     UIActivityTypeCopyToPasteboard,
                                     UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:YES completion:nil];

this is working fine in simulator, but when I am testing it on real ipad 3, it force closes saying the error

exc_bad_access code=1 address=0*0

in this line

activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, 
                                         UIActivityTypePrint,
                                         UIActivityTypePostToTwitter,
                                         UIActivityTypePostToWeibo,
                                         UIActivityTypeMail,
                                         UIActivityTypeCopyToPasteboard,
                                         UIActivityTypeSaveToCameraRoll];

can any one find me out what I have missed here?

edited part:

I have checked everything and array is not nil. if I comment out the line activityVc.exclude....

then it force closes and says

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller
Reyjohn
  • 2,654
  • 9
  • 37
  • 63
  • Check if `array` is nil – Kevin Aug 13 '13 at 16:47
  • It the array is nil then how it is working on simulator with the perfect image? – Reyjohn Aug 13 '13 at 16:50
  • If your `array` is not nil, check the `UIActivity` objects in the array and make sure they're constructed properly. Maybe something in that data is not correct. – stevekohls Aug 13 '13 at 16:58
  • @Reyjohn It is quite possible that `array` or `archive` could be `nil` on a real device on not on the simulator. Did you actually check? – rmaddy Aug 13 '13 at 17:03
  • Ok I am checking, but the error is showing in the line where I am excluding the other sharing apps and keeping just the facebook. So is there anything wrong? – Reyjohn Aug 13 '13 at 17:07

1 Answers1

0

Have you check your iPad's os?,

it must have ios 6 or above version for UIActivityViewController enter image description here

you can check version using

   NSString *reqSysVer = @"6.0";
   NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
    if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
      {

       //use UIActivityViewController here
      }
Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121