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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:59:29+00:00 2026-06-13T07:59:29+00:00

I am learning Objective-C through the iTunes University (Stanford). I am programming the sin

  • 0

I am learning Objective-C through the iTunes University (Stanford). I am programming the sin button and I am getting a Parse issue :

Expected Identifier on this line “double myDegrees = [self.operandStack];”.

CalculatorBrain.h

#import <Foundation/Foundation.h>


@interface CalculatorBrain : NSObject

-(void)pushOperand:(double)operand;
-(double)performOperation:(NSString *)operation;

@end

CalculatorBrain.m

#import "CalculatorBrain.h"

@interface CalculatorBrain()
@property (nonatomic, strong) NSMutableArray *operandStack;
@end

@implementation CalculatorBrain


@synthesize operandStack = _operandStack;

-(NSMutableArray *)operandStack
{
    if(_operandStack == nil) _operandStack = [[NSMutableArray alloc]init];
    return _operandStack;
}

-(void)pushOperand:(double)operand
{
    [self.operandStack addObject:[NSNumber numberWithDouble:operand]];
}

-(double)popOperand
{
    NSNumber *operandObject = [self.operandStack lastObject];
    if (operandObject) [self.operandStack removeLastObject];
    return [operandObject doubleValue];
}

-(double)performOperation:(NSString *)operation
{
    double result = 0;

if([operation isEqualToString:@"+"])
{
    result = [self popOperand] + [self popOperand];
} else if ([operation isEqualToString:@"*"])
{
    result = [self popOperand] * [self popOperand];
} else if ([operation isEqualToString:@"/"])
{
    result = [self popOperand] / [self popOperand];
} else if ([operation isEqualToString:@"-"])
{
    result = [self popOperand] - [self popOperand];
} else if ([operation isEqualToString:@"C"])
{
    [self.operandStack removeAllObjects];
    result = 0;
} else if ([operation isEqualToString:@"sin"])
{
    double myDegrees = [self.operandStack];
    NSLog(@"degrees are %f", myDegrees);
    double myRadian = myDegrees * M_1_PI/180;
    NSLog(@"radian is %f", myRadian);
    result = myRadian;
}else if ([operation isEqualToString:@"cos"])
{
    result = cos([self popOperand]);
}else if ([operation isEqualToString:@"sqrt"])
{
    result = sqrt([self popOperand]);
}


[self pushOperand:result];

return result;
}

@end

CalculatorViewController.h

#import <UIKit/UIKit.h>
#import <math.h>

@interface CalculatorViewController : UIViewController

@property (weak, nonatomic) IBOutlet UILabel *display;
@property (weak, nonatomic) IBOutlet UILabel *history;

@end

CalculatorViewController.m

#import "CalculatorViewController.h"
#import "CalculatorBrain.h"



@interface CalculatorViewController()
@property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;
@property (nonatomic, strong) CalculatorBrain *brain;
@end


@implementation CalculatorViewController

@synthesize display = _display;
@synthesize history = _history;
@synthesize userIsInTheMiddleOfEnteringANumber = _userIsInTheMiddleOfEnteringANumber;
@synthesize brain = _brain;

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

- (IBAction)digitPressed:(UIButton *)sender
{
    NSString *digit = sender.currentTitle;
    if (self.userIsInTheMiddleOfEnteringANumber)
{
    self.display.text = self.display.text = [self.display.text    stringByAppendingString:digit];
} else
{
    self.display.text = digit;
    self.userIsInTheMiddleOfEnteringANumber = YES;
}

self.history.text = self.history.text = [self.history.text stringByAppendingString: digit];

}

- (IBAction)opperationPresssed:(UIButton *)sender
{
    if (self.userIsInTheMiddleOfEnteringANumber) [self enterPressed];
    double result = [self.brain performOperation:sender.currentTitle];
    NSString *resultString = [NSString stringWithFormat:@"%g", result];
    self.display.text = resultString;
}

- (IBAction)enterPressed
{
    [self.brain pushOperand:[self.display.text doubleValue]];
    self.userIsInTheMiddleOfEnteringANumber = NO;
}

@end
  • 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-13T07:59:31+00:00Added an answer on June 13, 2026 at 7:59 am
    double myDegrees = [[self.operandStack objectAtIndex:0] doubleValue];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning objective-c, working through Aaron Hillegass' book Cocoa Programming for Mac OS X
I am learning Objective-C and iOS programming through the terrific iTunesU course posted by
Still learning Objective-C / iPhone SDK here. I think I know why this wasn't
I'm learning Objective-C but I'm stuck at this point where it comes to multiple
After spending three weeks learning Objective-C and Cocoa programming for my work, I've been
I'm interested in learning Objective C for iPhone development. This is a topic which
I'm following through one of the very early examples in Learning Objective-C on the
I want to start learning objective-c with book: Programming in Objective-C (4th Edition) .
I have started learning Objective C with no prior programming experience from the 'Become
I'm learning Objective-C and just trying out some sample code. I am getting the

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.