发布一张图片的代码:
-(IBAction)postImageToFacebook:(id)sender {
DLog(@"");
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:self.textField.text forKey:@"message"];
DLog(@"%@",[params objectForKey:@"message"]);
if(self.imageView.image){
DLog(@"not null");
UIImage *_img = self.imageView.image;
[params setObject:UIImagePNGRepresentation(_img) forKey:@"picture"];
}
[self performPublishAction:^{
[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
{
//showing an alert for failure
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"unable to post"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
else
{
//showing an alert for success
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Posted!"
message:@""
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}];
}];
}
我可以将另一个对象的重复键添加到 NSMutableDictionary 中吗?