In this recipe we will learn how to delete an item from a table view, as well our Core Data model.
Following on from our previous recipe, we will learn how to delete a row from our table view, and permanently remove this from our Core Data database.
To begin, follow the simple steps as outlined in the given order:
ViewController.m
implementation file, located within the SocialNetworkApp
folder.#pragma markSend a notification request to a group of friends - (void)sendNotificationRequest{ NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"invites you to check out some great stuff.", @"message", @"Check this out", @"notification_text",nil]; // Display the Facebook Request Notifications DialogBox [self.facebook dialog:@"apprequests" andParams:params andDelegate:self.mainDelegate]; } #pragma markFBDialogDelegate - (void)dialogDidComplete:(FBDialog *)dialog { NSLog(@"dialog completed successfully"); } #pragma markPost a message to the current user's Wall. - (void)postMessagetoWall{ NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"Testing FacebookSampleApp Feed Dialog", @"name", @"Using Feed Dialogs within iOS are great.", @"caption", @"Click to check out my BlockHeadz game on the AppStore", @"description", @"http://itunes.apple.com/app/blockheadz/ id386884355?mt=8#", @"link", @"http://geniesoftstudios.com/blog/wp- content/uploads/2011/03/blockhead.png",@"picture",nil]; // Display the Facebook feed dialog with our array. [self.facebook dialog:@"feed" andParams:params andDelegate:self.mainDelegate]; } #pragma mark called when user presses the Post Message Button - (IBAction)postMessage:(id)sender { // Define an instance of our action sheet UIActionSheet *actionSheet; // Initialize our action sheet with the // differen't mapping types. actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose from the list below" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Close" otherButtonTitles:@"Send Notification",@"Submit new post", @"Obtain User Details",nil]; // Set our Action Sheet style and then // display it to the user. actionSheet.actionSheetStyle = UIBarStyleBlackTranslucent; [actionSheet showInView:self.view]; } // Delegate that handles the chosen action sheet options -(void)actionSheet:(UIActionSheet *)actionSheetclickedButtonAtIndex:(NSInteger)buttonIndex{ // Determine the chosen item switch (buttonIndex) { case 1: [self sendNotificationRequest]; break; case 2: [self postMessagetoWall]; break; case 3: [self getGraphAPIData]; break; default: break; // Catch the Close button and exit. } }
In this recipe, we start by declaring an
NSMutableDictionary
object variable params
that will be used to pass the message and the notification text, using the @message
and @notification_text
parameters. We then use the dialog
method of our facebook
object, and tell the dialog that we want to use the apprequests
dialog. Next, we declare the method called dialogDidComplete
, which gets called if the requests
dialog gets successfully displayed to the user. In the postMessagetoWall:
method, we declare an NSMutableDictionary
object variable params
that will be used to pass the message and the notification text, using the @name
, @caption
, @description
, @link
, and @picture
properties. These define what
information is displayed when posting the messageto the user's wall. Next, we use the dialog
method of our facebook
object, and tell the dialog that we want to use the feed
dialog, since we are posting details to the wall.
Next, in our postMessage:
method, we declare and instantiate an actionsheet
object that is based on the UIActionSheet
class, and then initialize our action sheet to display the different types of actions we want to perform, to have displayed as the list of options to choose from. Next, we proceed to set the style for our action sheet using the actionSheetStyle
property of the UIActionSheet
class, and then display the action sheet into the current view using the showInView:self.view
method.
In our next part, we define a delegate method to determine the button that was pressed from the action sheet and used the clickedButtonAtIndex
method of the actionSheet
property. We then check the value of the buttonIndex
variable to determine the index of the button that was pressed.
The Facebook iOS SDK provides you with an easy way of making your applications integrate with the Facebook social channels. Using these social channels allows your users to submit posts to their wall, or send notification requests to their friends.
The iOS SDK provides you with a method to integrate through the social channels using the Facebook platform dialogs. The following table lists the dialogs that are currently supported by Facebook:
Social channel dialogs |
Description |
---|---|
This dialog is used for publishing posts to a user's news feed. | |
This type of dialog allows you to send a request to one or more of your friends. |
When using Facebook requests, these social channel dialogs provide you with a great way of allowing users to invite their friends to your iOS application or even accept gifts from their friends.
Requests are sent using the Request
dialog, and if the user's iOS device supports push
notifications, they will receive a push notification via the Facebook iOS application whenever a notification request is sent.