我需要验证医疗保险号码,并且我跟随此主题:How do I validate an Australian Medicare number?
我收到错误
代码是:String.Index does not have a member named advancedBy
let matches = expression.matchesInString(medicareNumber, options: NSMatchingOptions.ReportProgress, range: NSMakeRange(0, length))
if (matches.count > 0 && matches[0].numberOfRanges > 2) {
let base = medicareNumber.substringWithRange(medicareNumber.startIndex...medicareNumber.startIndex.advancedBy(matches[0].rangeAtIndex(1).length))
let checkDigitStartIndex = medicareNumber.startIndex.advancedBy(matches[0].rangeAtIndex(2).location )
let checkDigitEndIndex = checkDigitStartIndex.advancedBy(matches[0].rangeAtIndex(2).length)
let checkDigit = medicareNumber.substringWithRange(checkDigitStartIndex..<checkDigitEndIndex)
var total = 0
for i in 0..<multipliers.count {
total += Int(base.charAtIndex(i))! * multipliers[i]
}
return (total % 10) == Int(checkDigit)
}
我正在使用Xcode 6.2,我该如何解决这个问题?请注意我需要在没有升级Xcode的情况下解决这个问题。
答案 0 :(得分:0)
使用<span *ngIf="orderBy=='asc'" [ngStyle]="{'height': value+ '%'}"></span>
<span *ngIf="orderBy=='desc'" [ngStyle]="{'height': value+ '%'}"></span>
advance
let base = medicareNumber.substringWithRange(
medicareNumber.startIndex...advance(
medicareNumber.startIndex,
matches[0].rangeAtIndex(1).length
)
)
使用advance
advanceBy
let base = medicareNumber.substringWithRange(
medicareNumber.startIndex...medicareNumber.startIndex.advancedBy(
matches[0].rangeAtIndex(1).length
)
)
使用advancedBy(_:)
index(_:offsetBy:)