瀏覽代碼

Add minus sign rectification in output

master
Said Achmiz 9 年之前
父節點
當前提交
d58f0748bd
共有 3 個檔案被更改,包括 29 行新增6 行删除
  1. 3
    3
      SA_DB_StringFormatRules.plist
  2. 1
    1
      SA_DiceExpressionStringConstants.h
  3. 25
    2
      SA_DiceFormatter.m

+ 3
- 3
SA_DB_StringFormatRules.plist 查看文件

<key>SA_DB_VALID_OPERATOR_CHARACTERS</key> <key>SA_DB_VALID_OPERATOR_CHARACTERS</key>
<dict> <dict>
<key>SA_DB_OPERATOR_MINUS</key> <key>SA_DB_OPERATOR_MINUS</key>
<string>-–−</string>
<string>-–−﹣-</string>
<key>SA_DB_OPERATOR_PLUS</key> <key>SA_DB_OPERATOR_PLUS</key>
<string>+</string> <string>+</string>
<key>SA_DB_OPERATOR_TIMES</key> <key>SA_DB_OPERATOR_TIMES</key>
<key>SA_DB_CANONICAL_OPERATOR_REPRESENTATIONS</key> <key>SA_DB_CANONICAL_OPERATOR_REPRESENTATIONS</key>
<dict> <dict>
<key>SA_DB_OPERATOR_MINUS</key> <key>SA_DB_OPERATOR_MINUS</key>
<string>-</string>
<string></string>
<key>SA_DB_OPERATOR_PLUS</key> <key>SA_DB_OPERATOR_PLUS</key>
<string>+</string> <string>+</string>
<key>SA_DB_OPERATOR_TIMES</key> <key>SA_DB_OPERATOR_TIMES</key>
<string>*</string>
<string>×</string>
</dict> </dict>
<key>SA_DB_CANONICAL_ROLL_COMMAND_DELIMITER_REPRESENTATION</key> <key>SA_DB_CANONICAL_ROLL_COMMAND_DELIMITER_REPRESENTATION</key>
<string>d</string> <string>d</string>

+ 1
- 1
SA_DiceExpressionStringConstants.h 查看文件



// The value for the key SA_DB_CANONICAL_ROLL_COMMAND_DELIMITER_REPRESENTATION // The value for the key SA_DB_CANONICAL_ROLL_COMMAND_DELIMITER_REPRESENTATION
// is the canonical representation of the die roll command delimiter. // is the canonical representation of the die roll command delimiter.
extern NSString * const SA_DB_CANONICAL_ROLL_COMMAND_DELIMITER_REPRESENTATION;
extern NSString * const SA_DB_CANONICAL_ROLL_COMMAND_DELIMITER_REPRESENTATION;

+ 25
- 2
SA_DiceFormatter.m 查看文件

} }
} }
return formattedString;
// Make all instances of the minus sign be represented with the proper,
// canonical minus sign.
return [self rectifyMinusSignInString:formattedString];
} }


- (NSString *)legacyStringFromIntermediaryExpression:(NSDictionary *)expression - (NSString *)legacyStringFromIntermediaryExpression:(NSDictionary *)expression
[formattedString appendFormat:@"ERROR"]; [formattedString appendFormat:@"ERROR"];
} }
return formattedString;
// Make all instances of the minus sign be represented with the proper,
// canonical minus sign.
return [self rectifyMinusSignInString:formattedString];
} }


/****************************/ /****************************/
#pragma mark - Helper methods #pragma mark - Helper methods
/****************************/ /****************************/


- (NSString *)rectifyMinusSignInString:(NSString *)aString
{
__block NSMutableString* sameStringButMutable = aString.mutableCopy;
NSLog(@"%@", sameStringButMutable);
NSString *validMinusSignCharacters = [SA_DiceFormatter stringFormatRules][SA_DB_VALID_CHARACTERS][SA_DB_VALID_OPERATOR_CHARACTERS][SA_DB_OPERATOR_MINUS];
NSString *theRealMinusSign = [SA_DiceFormatter canonicalRepresentationForOperator:SA_DB_OPERATOR_MINUS];
[validMinusSignCharacters enumerateSubstringsInRange:NSMakeRange(0, validMinusSignCharacters.length)
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *character, NSRange characterRange, NSRange enclosingRange, BOOL *stop)
{
[sameStringButMutable replaceOccurrencesOfString:character withString:theRealMinusSign options:NSLiteralSearch range:NSMakeRange(0, sameStringButMutable.length)];
}];
NSLog(@"%@", sameStringButMutable);
return sameStringButMutable.copy;
}

+ (void)loadErrorDescriptions + (void)loadErrorDescriptions
{ {
NSString* errorDescriptionsPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"SA_DB_ErrorDescriptions" ofType:@"plist"]; NSString* errorDescriptionsPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"SA_DB_ErrorDescriptions" ofType:@"plist"];

Loading…
取消
儲存