有没有办法可以NSUserDefaults
在消息中同步数据Twitter
?
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"Cancelled");
} else
{
NSLog(@"Done");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
[controller setInitialText:@""];
[controller addURL:[NSURL URLWithString:@""]];
[controller addImage:[UIImage imageNamed:@""]];
[self presentViewController:controller animated:YES completion:Nil];
}
我需要设置初始文本来接受 nsuserdefaults,因为我有一些用户设置的借口。这是 nsuserdefaults。
NSString *savestring =field.text;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:savestring forKey:@"savedstring"];
[defaults synchronize];