Reputation: 16327
**I have added the Twitter.framework and Accounts.framework.
And imported the Twitter.h header file.
But I am getting the error "Use of undeclared identifier 'tweetSheet'"**
Class TWTweetComposeViewController = NSClassFromString(@"TWTweetComposeViewController");
if(TWTweetComposeViewController != nil) {
//For iOS 5.0 onwards
if ([TWTweetComposeViewController canSendTweet]) {
//Create the tweet sheet
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
//Customize the tweet sheet here
//Add a tweet message
[tweetSheet setInitialText:[[self getShareContent] objectForKey:@"twitterContent"]];
//Set a blocking handler for the tweet sheet
tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result){
if (TWTweetComposeViewControllerResultDone) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Tweeted"
message:@"You successfully tweeted"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
} else if (TWTweetComposeViewControllerResultCancelled) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Ooops..."
message:@"Something went wrong, try again later"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
[self dismissModalViewControllerAnimated:YES];
};
//Show the tweet sheet!
[self presentModalViewController:tweetSheet animated:YES];
} else {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
message:@"You need to configure your Twitter account in the Settings"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
Upvotes: 1
Views: 806
Reputation: 17898
The compiler is confused because you've created a variable (TWTweetComposeViewController
) which has the same name as a class name. Change the first 2 lines to:
Class tweetComposeViewController = NSClassFromString(@"TWTweetComposeViewController");
if(tweetComposeViewController != nil) {
...and you should be all good.
Upvotes: 1