Мой код выполняет вычисления после нажатия кнопки в «IBAction» и возвращает результат в виде строки в виде «сообщения» в «UIAlertView».
else{
NSString *str = [[NSString alloc] initWithFormat:@"You require an average GPA of at least %.2f to achieve your Goal of %@", gpagoal, (NSString *)[myPickerDelegate.myGoal objectAtIndex: [myPicker selectedRowInComponent:0]]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Nothing is Impossible"
message:str
delegate:self
cancelButtonTitle:@"Good Luck"
otherButtonTitles:@"Tweet",nil];
//show alert
[alert show];
[alert release];
NSLog(@"All Valid");
}
У меня проблема с тем, как извлечь значение "gpagoal" из метода вычисления "IBAction".
ниже - код отдельной кнопки для твита, которая работает, если я могу портировать значение gpagoal из другого метода.
- (IBAction)sendEasyTweet:(id)sender {
// Set up the built-in twitter composition view controller.
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
// i have problem trying to pull the result "gpagoal" from the calculation's "IBAction" method as i dunno how to pull out variable from a method to another method.
NSString *str2 = [[NSString alloc] initWithFormat:@"I need an average GPA of at least %.2f this semester to achieve my Goal of %@", gpagoal, (NSString *)[myPickerDelegate.myGoal objectAtIndex: [myPicker selectedRowInComponent:0]]];
// Set the initial tweet text. See the framework for additional properties that can be set.
[tweetViewController setInitialText:str2];
// Create the completion handler block.
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
//NSString *output;
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
// The cancel button was tapped.
//output = @"Tweet cancelled.";
NSLog(@"Tweet cancelled");
break;
case TWTweetComposeViewControllerResultDone:
// The tweet was sent.
//output = @"Tweet done.";
NSLog(@"Tweet done");
break;
default:
break;
}
// Dismiss the tweet composition view controller.
[self dismissModalViewControllerAnimated:YES];
}];
// Present the tweet composition view controller modally.
[self presentModalViewController:tweetViewController animated:YES];
}