Ios NSObject没有名为startIndex的成员
今天早些时候在一个“类似”的项目中工作,现在它给出了错误 “NSObject”没有名为“startIndex”的成员 所以,我试着:Ios NSObject没有名为startIndex的成员,ios,swift,xcode6.3,Ios,Swift,Xcode6.3,今天早些时候在一个“类似”的项目中工作,现在它给出了错误 “NSObject”没有名为“startIndex”的成员 所以,我试着: @IBAction func logEmButn(sender: AnyObject) { let clonCountrLableItem = clonCountLable.text! let baclCounterLableItem = baclCountLable.text! let ironCountLableItem = ironC
@IBAction func logEmButn(sender: AnyObject) {
let clonCountrLableItem = clonCountLable.text!
let baclCounterLableItem = baclCountLable.text!
let ironCountLableItem = ironCountLable.text!
let gymCountLableItem = gymCountLable.text!
let asp2CountLableItem = asp2CountLable.text!
let fiveHtpLableItem = fiveHtpLable.text!
let selectedLables = [clonCountLable, baclCountLable, ironCountLable, gymCountLable, asp2CountLable, fiveHtpLable]
for selectedLable in selectedLables {
if selectedLable != "0 s" {
println("You took \(selectedLable[selectedLable.startIndex])")
这给出了一个类似的错误,但以。。。命名为“下标”
也尝试过:
println("You took \(selectedLable[selectedLable.description]) \(keyOfselectedLables)")
运行时出现以下错误:无法将“UILable”(0x199943e30)类型的值强制转换为“NSString”(0x198fb2768)。请参阅下面的代码,selectedLables是UILabel的数组
let lable = "rick"
for index in indices(lable) {
print("\(lable[index])")
}
但是在if语句中,您将UILabel类型的selectedLable与字符串常量相等
let selectedLables = [clonCountLable, baclCountLable, ironCountLable, gymCountLable, asp2CountLable, fiveHtpLable]
由于selectedLable不是字符串类型,因此它没有startIndex属性或索引
所以我认为数组应该是
for selectedLable in selectedLables {
if selectedLable != "0 s"
尼提希·乔治搞定了。(我在这里看到的最后一个答案)对不起,如果我把这里的流程搞砸了,total nube 你在这里没有提供足够的信息。请先说明如何声明
selectedLable
。PSA:Label的拼写为“Label”。尼希希·乔治:你挽救了这一天,现在一切都正常,非常感谢!!如果您的问题已完全解决,请将其标记为您问题的答案。
let selectedLables = [baclCounterLableItem, ironCountLableItem, gymCountLableItem, asp2CountLableItem, fiveHtpLableItem]