我遇到了一个自动发布问题,我相信行let searchTerm : String = newValue.uppercaseString
有问题的代码是由obj-c调用的快速代码。
当我删除uppercaseString
代码时,我的软件似乎没有发生任何不好的事情,而当它的内容变得混乱时。有什么东西明显我错过了吗?像@synchronized
电话或其他什么?
///Section 3.5.1.11 - Consist of 8 Characters 0-9 and A-Z and Space - truncates trailing spaces
var callsign: String {
get {
let callsignArray: [UInt8] = [bytes[19], bytes[20], bytes[21], bytes[22], bytes[23], bytes[24], bytes[25], bytes[26]]
let callsignString = NSString(bytes: callsignArray, length: callsignArray.count, encoding: NSUTF8StringEncoding)
let ret = callsignString! as! String
return ret.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
}
set {
// Make string uppercase
let searchTerm : String = newValue.uppercaseString
// Scan for invalid characters
let regex = NSRegularExpression(pattern: "[^A-Z0-9 ].*", options: nil, error: nil)!
if regex.firstMatchInString(searchTerm, options: nil, range: NSMakeRange(0, count(searchTerm))) != nil {
NSException(name:"name", reason:"Invalid character past into Callsign", userInfo:nil).raise()
} else {
println("No special characters")
}
var acid: String = searchTerm;
// Truncate to length
while (count(acid) < 8) {
acid = acid + [" "]
}
// Assign only 8 characters to string
let buf = [UInt8](acid.utf8)
for (var i = 0; i <= 7; i++) {
bytes[19 + i] = buf[i]
}
}
}
}