Post: [Obj-C] Mac Calculator
06-09-2011, 05:39 PM #1
GQGK
Skillz
(adsbygoogle = window.adsbygoogle || []).push({}); So I got board and made a fully functioning calculator for mac (since the only calculator is spotlight). I'll probably release the source code for this version once I add some more features. Try it out and let me know what you think please. If you're on windows, check out the screenshot (and take my word that it works as far as I've tested it Winky Winky). Thank you for the help!

Btw this is super lightweight (full GUI and the screenshot is a larger file size than the zip file :p), opens instantly, and provides all basic features of a calculator. More will be added soon. Change log can be found in the download. If you guys really want a virus scan let me know. Too busy to do it atm.

Screenshot: You must login or register to view this content.
Download: You must login or register to view this content.

UPDATE: Adding source code later today for anyone to look at. Too long to post here with code tags.

    //
// CalculatorAppDelegate.m
// Calculator
//
// Created by Dustin Riley on 6/7/11.
// Copyright 2011 Dustin Riley. All rights reserved.
//

#import "CalculatorAppDelegate.h"

@implementation CalculatorAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
thingOne = 0;
thingTwo = 0;
edit = @"";
editMute = [edit mutableCopy];
NSLog(@"It is %@", edit);
NSLog(@"Mute is %@", editMute);
reverse = 1;
}

- (IBAction) buttonClicked: (id) sender
{
if ([sender isEqual: one])
{
[editMute appendStringAngry"1"];
edit = editMute;
NSLog(@"It is %@", edit);
[EditText setStringValue:edit];
}
else if([sender isEqual: two]){
[editMute appendStringAngry"2"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: three]){
[editMute appendStringAngry"3"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: four]){
[editMute appendStringAngry"4"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: five]){
[editMute appendStringAngry"5"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: six]){
[editMute appendStringAngry"6"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: seven]){
[editMute appendStringAngry"7"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: eight]){
[editMute appendStringAngry"8"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: nine]){
[editMute appendStringAngry"9"];
edit = editMute;
[EditText setStringValue:edit];
}
else if([sender isEqual: zero]){
if([edit isEqualToStringAngry""]){

}
else{
[editMute appendStringAngry"0"];
edit = editMute;
[EditText setStringValue:edit];
}
}
else if([sender isEqual:add]){
if([edit isEqualAngry""]){
operation = @"add";
}
else{
if(reverse == 1){
thingOne = [edit doubleValue];
edit = @"";
[editMute setString:edit];
[EditText setStringValueAngry"0"];
reverse = 2;
NSLog(@"It is %@", operation);
operation = @"add";
NSLog(@"It is %@", operation);
}
else{
NSLog(@"1 is %@", operation);
[self operationThingAngry"add"];
operation = @"add";
NSLog(@"2 is %@", operation);
}
}
}
else if([sender isEqual:subtract]){
if([edit isEqualAngry""]){
operation = @"subtract";
}
else{
if(reverse == 1){
thingOne = [edit doubleValue];
edit = @"";
[editMute setString:edit];
[EditText setStringValueAngry"0"];
reverse = 2;
NSLog(@"It is %@", operation);
operation = @"subtract";
NSLog(@"It is %@", operation);
}
else{
NSLog(@"It is %@", operation);
[self operationThingAngry"subtract"];
operation = @"subtract";
NSLog(@"It is %@", operation);
}
}
}
else if ([sender isEqual:clear]){
thingOne = 0;
thingTwo = 0;
edit = @"";
[editMute setString:edit];
[EditText setStringValueAngry"0"];
reverse = 1;
operation = @"";
}
else if([sender isEqual:equal]){
NSLog(@"Before it is %@", operation);
[self operationThingGaspperation];
NSLog(@"After it is %@", operation);
}
else if([sender isEqual:divide]){
if([edit isEqualAngry""]){
operation = @"divide";
}
else{
if(reverse == 1){
thingOne = [edit doubleValue];
edit = @"";
[editMute setString:edit];
[EditText setStringValueAngry"0"];
reverse = 2;
NSLog(@"It is %@", operation);
operation = @"divide";
NSLog(@"It is %@", operation);
}
else{
NSLog(@"It is %@", operation);
[self operationThingAngry"divide"];
operation = @"divide";
NSLog(@"It is %@", operation);
}
}
}
else if([sender isEqual:multiply]){
if([edit isEqualAngry""]){
operation = @"multiply";
}
else{
if(reverse == 1){
thingOne = [edit doubleValue];
edit = @"";
[editMute setString:edit];
[EditText setStringValueAngry"0"];
reverse = 2;
NSLog(@"It is %@", operation);
operation = @"multiply";
NSLog(@"It is %@", operation);
}
else{
NSLog(@"It is %@", operation);
[self operationThingAngry"multiply"];
operation = @"multiply";
NSLog(@"It is %@", operation);
}
}
}
else if([sender isEqual:point]){
if([edit isEqualAngry""]){

}
else{
[editMute appendStringAngry"."];
edit = editMute;
NSLog(@"It is %@", edit);
[EditText setStringValue:edit];
}
}
}

-(void) operationThing:(NSString*)next;
{
if([operation isEqualAngry"add"]){
thingTwo = [edit doubleValue];
answer = thingOne + thingTwo;
thingOne = answer;
NSLog(@"The answer is %f", answer);
NSString* myAnswer = [NSString stringWithFormatAngry"%f", answer];
[EditText setStringValue:myAnswer];
edit = @"";
[editMute setString:edit];
}
else if([operation isEqualAngry"subtract"]){
thingTwo = [edit doubleValue];
answer = thingOne - thingTwo;
thingOne = answer;
NSLog(@"The answer is %f", answer);
NSString* myAnswer = [NSString stringWithFormatAngry"%f", answer];
[EditText setStringValue:myAnswer];
edit = @"";
[editMute setString:edit];
}
else if([operation isEqualAngry"divide"]){
thingTwo = [edit doubleValue];
answer = thingOne/thingTwo;
thingOne = answer;
NSLog(@"The answer is %f", answer);
NSString* myAnswer = [NSString stringWithFormatAngry"%f", answer];
[EditText setStringValue:myAnswer];
edit = @"";
[editMute setString:edit];
}
else if([operation isEqualAngry"multiply"]){
thingTwo = [edit doubleValue];
answer = thingOne*thingTwo;
thingOne = answer;
NSLog(@"The answer is %f", answer);
NSString* myAnswer = [NSString stringWithFormatAngry"%f", answer];
[EditText setStringValue:myAnswer];
edit = @"";
[editMute setString:edit];
}
operation = next;
}

@end
(adsbygoogle = window.adsbygoogle || []).push({});
06-10-2011, 04:44 AM #2
GQGK
Skillz
Well... added the .m file source code here anyway... lol enjoy. my .h file will be shown later Smile

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo