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

  • SEARCH
  • Home
  • 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 9250657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:29:48+00:00 2026-06-18T10:29:48+00:00

im very new to objective c and making apps and not really sure why

  • 0

im very new to objective c and making apps and not really sure why this is not building. here is my code that is failing:
CalculatorViewController.m

#import "CalculatorViewController.h"

@interface CalculatorViewController ()

@end

@implementation CalculatorViewController
-(CalculatorBrain *)brain
{
    if (!brain){
        brain = [[CalculatorBrain alloc] init];
    }
    return brain;
}

-(IBAction)digitPressed:(UIButton *)sender;
{
    NSString *digit = [[sender titleLabel] text];
    if (userIsInTheMiddleOfTypingANumber){
        [display setText:[[display text] stringByAppendingString:digit]];
    } else{
            [display setText:digit];
        userIsInTheMiddleOfTypingANumber = YES;
        }

}
-(IBAction)operationPressed:(UIButton *)sender;
{
    if (userIsInTheMiddleOfTypingANumber){
        [[self brain] setOperand:[[display text] doubleValue]];
        userIsInTheMiddleOfTypingANumber = NO;
    }
    NSString *operation = [[sender titleLabel] text];
    double result = [[self brain] performOperation:operation];
    [display setText:[NSString stringWithFormat:@"%g", result]];
}

@end

and CalculatorViewController.h

   #import <UIKit/UIKit.h>
#import "CalculatorBrain.h"

@interface CalculatorViewController : UIViewController{
    IBOutlet UILabel *display;
    CalculatorBrain *brain;
    BOOL userIsInTheMiddleOfTypingANumber;
}

-(IBAction)digitPressed:(UIButton *)sender;
-(IBAction)operationPressed:(UIButton *)sender;


@end

double result = [[self brain] performOperation:operation]; at the very end of the CalculatorViewController.m is where I get the error Initializing ‘double’ with an expression of incompatible type ‘void’
What does this mean or where should I look to fix this?

  • 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-06-18T10:29:49+00:00Added an answer on June 18, 2026 at 10:29 am

    performOperation: will probably be declared as

    - (void)performOperation:(NSString*)operation;
    

    As you can see, the return of this is void. This means it doesn’t return anything, as such, you’re trying to assign a void return to a double, which is invalid.

    The problem will either be in the header file, or the implementation file where it has been implemented. Look at the method signature to see if it contains void.

    To fix, either don’t assign to a double variable, or (more preferable I assume) allow performOperation: to return a double value.

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

Sidebar

Related Questions

First off I am very new to Objective C and iPhone programming. Now that
So I'm still very new to this whole objective C think and I ran
I am very new to Objective C and HTTPs. Please advise me on this
i am still very new to objective c and in fact this is my
I'm very new to Objective C. I have a class PassageViewController. Here's the .h
I'm very new to Objective-C, so this is probably very basic. Anyhow, I am
I am very new to Objective-C. Here is what I want. I have a
i am very new to objective-c, but i want to make some app that
I'm very new to objective C. I followed the tutorial for integrating Facebook to
I'm very new to Objective-C, and am having some beginner issues. I have an

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.