I am trying to post a picture from my app to twitter account. It works fine on my 3 devices but crashes for one of my friends. I am using the following code… Wasted almost 2 days on it so far without any luck. Please see the Problem lines, app crashes on those two lines as per crashalytics. Any one has experienced this?
NSString *account_id = [PFUser currentUser][@“Twitter_ScreenName”];
NSURL *retweetURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update_with_media.json"];
//Problem
NSDictionary *params = @{@"status" : [NSString stringWithFormat:@"%@#mytag",self.postTextView.text]};
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:retweetURL
parameters:params];
NSData *imageData = UIImageJPEGRepresentation(self.postImage, 0.5f);
[request addMultipartData:imageData withName:@"media[]" type:@"image/jpeg" filename:@"image.jpg"];
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error)
{
if (granted == YES)//Problem
{
NSArray *twitterAccounts =
[account accountsWithAccountType:accountType];
if ([twitterAccounts count] > 0)
{
ACAccount *twitterAccount;
for (int i=0; i<[twitterAccounts count]; i++)
{
ACAccount *acc=[twitterAccounts objectAtIndex:i];
if ([acc.username isEqualToString: account_id ])
{
twitterAccount = acc;
break;
}
}