Facebookとデータを共有しようとしています。iPhoneのメモリにローカルに保存されている画像以外のデータを共有できます。しかし、パラメーター @"source" を使用してローカルに保存された画像を共有しようとすると、アプリがエラー "[NSConcreteMutableData _fastCharacterContents]" で終了します。
ローカル イメージを共有するために、@"source" パラメーターの必要に応じて、それを NSData に変換しています。
NSData *data = [NSData dataWithContentsOfURL:localUrl];
__block ACAccount *facebookAccount = nil;
ACAccountType *facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{
ACFacebookAppIdKey: @"xxxxxxxxxxxxxx",
ACFacebookPermissionsKey: @[@"email"],
ACFacebookAudienceKey: ACFacebookAudienceEveryone
}; // basic read permissions
[self.accountStore requestAccessToAccountsWithType:facebookAccountType
options:options completion:^(BOOL granted, NSError *e)
{
if (granted) {
// Now that you have publish permissions execute the request
NSDictionary *options2 = @{
ACFacebookAppIdKey: @"xxxxxxxxxxxxxx",
ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:options2 completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
/*NSDictionary *parameters = @{@"message": @"This is a test",
@"name": @"Sharing Tutorial",
@"caption": @"Build great social apps and get more installs.",
@"description": @"Allow your users to share stories on Facebook from your app using the iOS SDK.",
@"link": @"https://developers.facebook.com/docs/ios/share/",
@"source":data};*/
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"My hat image", @"message", data, @"source", nil];
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:parameters];
NSLog(@"AnythingHere?");
[feedRequest setAccount:facebookAccount];
[feedRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
// Handle response
NSLog(@"%@%@", error,urlResponse);
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:nil];
NSLog(@"Facebook Response : %@",response);
}];
}
else {
NSLog(@"Access denied 2");
NSLog(@"%@", [error description]);
}
}];
} else {
NSLog(@"Error: %@", [e description]);
NSLog(@"Access denied");
}
}];
このエラーの原因は何ですか?