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 992263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:14:17+00:00 2026-05-16T06:14:17+00:00

OK, so I have my main.m program code, and mvds suggested I free the

  • 0

OK, so I have my main.m program code, and mvds suggested I free the allocated memory I borrowed from my class when I created a new instance.

For some reason, when I attempt to free the memory using

[converter free];

It gives me a warning saying that converter may not respond to -free, and once I finish my program, it spits out a bunch of junk when I try to loop back to the beginning, or when I try to terminate the program.

I think it may have to do with either where I’m trying to free the memory, as it may be off, or, it has to do with my loop I have set up.

Here is my main.m code:

#import <Cocoa/Cocoa.h>
#import "class.h"

int main(int argc, char *argv[])
{
    int result;
    int prompt, prompt2;
    int loop = 1;
    double sourceTemp;

    while (loop == 1) {
        printf("\nWlecome to Bossverter, the one-stop shop for all of your temperature converting needs!  Please choose a source temperature scale:\n[1] Fahrenheit\n[2] Celsius\n[3] Kelvin\n[4] Rankine\n\n");

        result = scanf("%i", &prompt);

        if (result != 1)
            printf("Bossverter couldn't understand your input, Bossverter only needs one number!");

        else if (result == EOF)
            printf("Bossverter apologizes, Bossverter encountered an error when trying to read your input.");

        else if (result == 1)
        {
            printf("\nNow, please enter the temperature you would like to convert:\n\n");

            scanf("%lf", &sourceTemp);

            TemperatureConverter *converter = [[TemperatureConverter alloc] init];

            switch (prompt) 
            {
                case 1:
                    //end-user chooses Fahrenheit
                    [converter setFahrenheitValue:sourceTemp];
                    break;

                case 2:
                    //end-user chooses Celsius
                    [converter setCelsiusValue:sourceTemp];
                    break;

                case 3:
                    //end-user chooses Kelvin
                    [converter setKelvinValue:sourceTemp];
                    break;

                case 4:
                    //end-user chooses Rankine
                    [converter setRankineValue:sourceTemp];
                    break;
            }

            printf("\nNow, please choose a target temperature scale:\n[1] Fahrenheit\n[2] Celsius\n[3] Kelvin\n[4] Rankine\n\n");

            scanf("%i", &prompt2);

            char *scales[4] = { "Fahrenheit", "Celsius", "Kelvin", "Rankine" }; 

            switch (prompt2) 
            {
                case 1:
                    //end-user chooses Fahrenheit
                    printf("\n%lf degrees %s is %lf degrees Fahrenheit\n", sourceTemp, scales[prompt-1], [converter fahrenheitValue]);
                    break;

                case 2:
                    //end-user chooses Celsius
                    printf("\n%lf degrees %s is %lf degrees Celsius\n", sourceTemp, scales[prompt-1], [converter celsiusValue]);
                    break;

                case 3:
                    //end-user chooses Kelvin
                    printf("\n%lf degrees %s is %lf degrees Kelvin\n", sourceTemp, scales[prompt-1], [converter kelvinValue]);
                    break;

                case 4:
                    //end-user chooses Rankine
                    printf("\n%lf degrees %s is %lf degrees Rankine\n", sourceTemp, scales[prompt-1], [converter rankineValue]);
                    break;
            }

            printf("\nI'm glad you just Bossverted something.  Would you like to Bossvert again?\n[1] Yes!\n[2] No way man, I'm OUT!\n\n");

            scanf("%i", &loop);

            [converter free];

        }

    }



    return 0;
}
  • 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-16T06:14:18+00:00Added an answer on May 16, 2026 at 6:14 am
    1. You don’t have an NSAutoreleasePool – that’s dangerous (and probably wrong).
    2. Use release, not free.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.