Sharing string via AirDrop

1k views Asked by At

I'm trying to send a string by using AirDrop. The problem is that I don't know how to use NSURL to send a string from UITextField. How can I share NSString from UITextField by using AirDrop? The following is my IBAction code. However, sending part is failed.

-(IBAction)sendButton:(id)sender { 

NSURL *url = [NSURL URLWithString:self.inputTextField.text];
NSArray *objectsToShare = @[url];

//NSLog(@"you type: %@", self.inputTextField.text);

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

// Exclude all activities except AirDrop.
NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,
                                UIActivityTypePostToWeibo,
                                UIActivityTypeMessage, UIActivityTypeMail,
                                UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
                                UIActivityTypeAssignToContact,        UIActivityTypeSaveToCameraRoll,
                                UIActivityTypeAddToReadingList,  UIActivityTypePostToFlickr,
                                UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;

// Present the controller
[self presentViewController:controller animated:YES completion:nil];

//[self.readTextView setText:self.inputTextField.text];

}
0

There are 0 answers