From 43b907ba88804363ac346e862f363ed50a7f7576 Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Thu, 31 Aug 2017 00:03:24 +0200 Subject: [PATCH] Add Documentation and Clean Code --- MathKit/MPExpressionView.m | 4 +++- MathKit/MPFractionFunctionLayout.m | 4 ++-- MathKit/MPFractionTerm.h | 2 +- MathKit/MPSumFunction.h | 8 ++++---- MathKit/MPSumFunctionTerm.m | 5 ++--- 5 files changed, 12 insertions(+), 11 deletions(-) mode change 100644 => 100755 MathKit/MPExpressionView.m mode change 100644 => 100755 MathKit/MPFractionFunctionLayout.m mode change 100644 => 100755 MathKit/MPFractionTerm.h mode change 100644 => 100755 MathKit/MPSumFunction.h mode change 100644 => 100755 MathKit/MPSumFunctionTerm.m diff --git a/MathKit/MPExpressionView.m b/MathKit/MPExpressionView.m old mode 100644 new mode 100755 index 8a6405d..eac3884 --- a/MathKit/MPExpressionView.m +++ b/MathKit/MPExpressionView.m @@ -713,7 +713,9 @@ if (self.functionsPopover.isShown) { [self.functionsPopover close]; } else { - [self.functionsPopover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge]; + [self.functionsPopover showRelativeToRect:[sender bounds] + ofView:self.functionsButton + preferredEdge:NSMaxYEdge]; } } diff --git a/MathKit/MPFractionFunctionLayout.m b/MathKit/MPFractionFunctionLayout.m old mode 100644 new mode 100755 index eea7dfd..d6c8198 --- a/MathKit/MPFractionFunctionLayout.m +++ b/MathKit/MPFractionFunctionLayout.m @@ -11,8 +11,8 @@ #import "MPFractionFunction.h" -#define kFractionFunctionLineWidth 1.0 -#define kFractionFunctionHorizontalInset 2.0 +#define kFractionFunctionLineWidth 1 +#define kFractionFunctionHorizontalInset 2 #define kFractionFunctionNominatorOffset 0 #define kFractionFunctionDenominatorOffset 0 diff --git a/MathKit/MPFractionTerm.h b/MathKit/MPFractionTerm.h old mode 100644 new mode 100755 index 69f93f1..53e7dac --- a/MathKit/MPFractionTerm.h +++ b/MathKit/MPFractionTerm.h @@ -24,7 +24,7 @@ @abstract Represens a @link //apple_ref/occ/cl/MPFractionFunction@/link. - @discussion A fraction is evaluating by dividing the numerator by the + @discussion A fraction is evaluated by dividing the numerator by the denominator. */ @interface MPFractionTerm : MPFunctionTerm diff --git a/MathKit/MPSumFunction.h b/MathKit/MPSumFunction.h old mode 100644 new mode 100755 index c25c6e3..27e01d5 --- a/MathKit/MPSumFunction.h +++ b/MathKit/MPSumFunction.h @@ -29,9 +29,9 @@ the start expression and the target expressions are included in the iterations. - Each iteration the sum value is incremented by 1. If - the start and target expression evaluate to the same value the - sum is evaluated once. + Each iteration the iteration value is incremented by + 1. If the start and target expression evaluate to + the same value the sum is evaluated once. */ @interface MPSumFunction : MPFunction @@ -41,7 +41,7 @@ @discussion The start expression must define a variable that may be used in the sum expression. If the start expression does not define a - variable the sum function will fail on validation. + variable the sum function will not be evaluatable. */ @property (nonatomic, strong) MPExpression *startExpression; /* Index 0 */ diff --git a/MathKit/MPSumFunctionTerm.m b/MathKit/MPSumFunctionTerm.m old mode 100644 new mode 100755 index 9611e92..9acb178 --- a/MathKit/MPSumFunctionTerm.m +++ b/MathKit/MPSumFunctionTerm.m @@ -17,13 +17,12 @@ - (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error { MPParsedExpression *startExpression = [self expressionAtIndex:0]; - MPParsedExpression *sumExpression = [self expressionAtIndex:2]; - NSDecimalNumber *start = [startExpression evaluate:error]; ReturnNilIfNil(start); MPEvaluateExpression(target, 1); - NSDecimalNumber *value = [NSDecimalNumber zero]; + MPParsedExpression *sumExpression = [self expressionAtIndex:2]; + NSDecimalNumber *value = [NSDecimalNumber zero]; for (NSDecimalNumber *current = start; [current compare:target] <= 0; current = [current decimalNumberByAdding:[[NSDecimalNumber alloc] initWithInteger:1]]) {