else if(sender == btn){
NSString *str = @"";
intResult = 0;
flag = @"";
[tfShow setStringValue:str];
tfResult = str;
}else if(sender == btnAdd){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"+"];
[tfShow setStringValue:str];
if(![flag isEqual: @"+"]){
if([flag isEqual: @"-"]){
intResult = intResult-[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"*"]){
intResult = intResult*[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"/"]){
intResult = intResult/[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual: @""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"+";
}else if([flag isEqual: @"+"]){
intResult = intResult+[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnSub){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"-"];
[tfShow setStringValue:str];
if(![flag isEqual: @"-"]){
if([flag isEqual: @"+"]){
intResult = intResult+[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"*"]){
intResult = intResult*[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"/"]){
intResult = intResult/[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual:@""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"-";
}else if([flag isEqual: @"-"]){
intResult = intResult-[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnMul){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"*"];
[tfShow setStringValue:str];
if(![flag isEqual: @"*"]){
if([flag isEqual: @"+"]){
intResult = intResult+[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"-"]){
intResult = intResult-[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"/"]){
intResult = intResult/[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual:@""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"*";
}else if([flag isEqual: @"*"]){
intResult = intResult*[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnDiv){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"/"];
[tfShow setStringValue:str];
if(![flag isEqual: @"/"]){
if([flag isEqual: @"+"]){
intResult = intResult+[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"-"]){
intResult = intResult-[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"*"]){
intResult = intResult*[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual:@""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"/";
}else if([flag isEqual: @"/"]){
intResult = intResult/[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnResult){
if([flag isEqual: @"+"]){
flag = @"y";
intResult = intResult+[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}else if([flag isEqual: @"-"]){
flag = @"y";
intResult = intResult-[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}else if([flag isEqual: @"*"]){
flag = @"y";
intResult = intResult*[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}else if([flag isEqual: @"/"]){
flag = @"y";
intResult = intResult/[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}
}
}
@end
NSString *str = @"";
intResult = 0;
flag = @"";
[tfShow setStringValue:str];
tfResult = str;
}else if(sender == btnAdd){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"+"];
[tfShow setStringValue:str];
if(![flag isEqual: @"+"]){
if([flag isEqual: @"-"]){
intResult = intResult-[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"*"]){
intResult = intResult*[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"/"]){
intResult = intResult/[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual: @""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"+";
}else if([flag isEqual: @"+"]){
intResult = intResult+[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnSub){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"-"];
[tfShow setStringValue:str];
if(![flag isEqual: @"-"]){
if([flag isEqual: @"+"]){
intResult = intResult+[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"*"]){
intResult = intResult*[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"/"]){
intResult = intResult/[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual:@""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"-";
}else if([flag isEqual: @"-"]){
intResult = intResult-[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnMul){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"*"];
[tfShow setStringValue:str];
if(![flag isEqual: @"*"]){
if([flag isEqual: @"+"]){
intResult = intResult+[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"-"]){
intResult = intResult-[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"/"]){
intResult = intResult/[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual:@""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"*";
}else if([flag isEqual: @"*"]){
intResult = intResult*[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnDiv){
NSUInteger location = [tfShow stringValue].length;
NSString *str = [NSString stringWithFormat:@"%@%@",[tfShow stringValue],@"/"];
[tfShow setStringValue:str];
if(![flag isEqual: @"/"]){
if([flag isEqual: @"+"]){
intResult = intResult+[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"-"]){
intResult = intResult-[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else if([flag isEqual: @"*"]){
intResult = intResult*[[[tfShow stringValue]substringFromIndex:location+1]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}else{
if([tfResult isEqual:@""]){
NSUInteger location = [tfShow stringValue].length;
tfResult = [[tfShow stringValue]substringToIndex:location-1];
}
intResult = [tfResult intValue];
}
flag = @"/";
}else if([flag isEqual: @"/"]){
intResult = intResult/[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
}
}else if(sender == btnResult){
if([flag isEqual: @"+"]){
flag = @"y";
intResult = intResult+[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}else if([flag isEqual: @"-"]){
flag = @"y";
intResult = intResult-[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}else if([flag isEqual: @"*"]){
flag = @"y";
intResult = intResult*[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}else if([flag isEqual: @"/"]){
flag = @"y";
intResult = intResult/[[tfShow stringValue]intValue];
NSString *stringInt = [NSString stringWithFormat:@"%d",intResult];
tfResult = stringInt;
[tfShow setStringValue:tfResult];
}
}
}
@end