Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7003155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:01:37+00:00 2026-05-27T21:01:37+00:00

My code does a calculation upon a button press in IBAction and returns the

  • 0

My code does a calculation upon a button press in “IBAction” and returns the result in a string as the “message” in “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");
}

i have a problem of how to pull the “gpagoal” value from the calculation’s “IBAction” method.

below is the code for the standalone button for tweeting, which works if i am able to port over the gpagoal value from the other method.

- (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];

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:01:38+00:00Added an answer on May 27, 2026 at 9:01 pm

    You simply need a variable that is available throughout your class

    // ViewController.h
    
    ...
    @interface ViewController : UIViewController {
       double gpagoal;
    }
    

    Make sure it is properly initialized and updated as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code does not compile: public class GenericsTest { public static void main(String[]
The following Code does not compile Dim BasicGroups As String() = New String() {Node1,
The following code does not want to compile. See the included error message. Code:
I've written this very badly optimized C code that does a simple math calculation:
This code does not seem to compile, I just need to write something to
This code does not throw an error but the query fails, that is, the
This code does a redirect, but uses a 302 status code: <cflocation url=http://stackoverflow.com addToken=no
My code does not update the thread field. It is null. Anyone have any
My code does not pull the proper link for the item. Instead it's getting
This code does not function as expected: // $field contains the name of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.