UIActivityViewController how to convert string to print
ios6, objective-c
Solution
Got it. It doesn't take NSData directly, it takes UISimpleTextPrintFormatter.
NSString *textToShare = self.note.note;
UISimpleTextPrintFormatter *printData = [[UISimpleTextPrintFormatter alloc]
initWithText:textToShare];
NSArray *itemsToShare = [[NSArray alloc] initWithObjects:textToShare,printData, nil];
shareVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
shareVC.excludedActivityTypes = [[NSArray alloc] initWithObjects:UIActivityTypeSaveToCameraRoll, UIActivityTypePostToWeibo, nil];
Problem
I'm using UIActivityViewController to share some text from my app. I can send the text to messages, email, copy etc but I can't send it to print. I see UIActivityTypePrint takes a datatype of NSData. How can I create UIActivityViewController to take my string as both a string and NSData so that the view has the print option available? ``` NSString *textToShare = self.note.note; NSArray *itemsToShare = [[NSArray alloc] initWithObjects:textToShare, nil]; shareVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil]; shareVC.excludedActivityTypes = [[NSArray alloc] initWithObjects:UIActivityTypeSaveToCameraRoll, UIActivityTypePostToWeibo, nil]; ```