(swift2)变量在if语句中未更改

(swift2)变量在if语句中未更改,swift,swift2,Swift,Swift2,我面临的问题是,我无法更新变量lin。我已尝试使用多个变量a f:)。进入代码中的relevode quick第二行是识别变量的地方,如果你滚动到代码底部,则该变量将发生变化,但不会发生变化 let menable = UITabletgView() let arfSorces:[String] = ["C"] public func runMenu(){ if let window = UIApplication.sharedApplication().keyWindow{

我面临的问题是,我无法更新变量lin。我已尝试使用多个变量a f:)。进入代码中的relevode quick第二行是识别变量的地方,如果你滚动到代码底部,则该变量将发生变化,但不会发生变化

let menable = UITabletgView()
let arfSorces:[String] = ["C"]




public func runMenu(){
    if let window = UIApplication.sharedApplication().keyWindow{

        dimming.frame = window.frame
        dimming.backgroundColor = UIColor(white: 0.9, alpha: 0.5087)

        dimming.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("eefefef")))

        let height: CGFloat = 100000
        let y = window.frame.height - height + height
        menuTable.frame = CGRect(x: 10, y: window.frame.height, width: window.frame.height, height: height)

        window.addSubview(dimming)
        window.addSubview(mee)

       eView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("c", forIndexPath: indexPath)as UITableViewCell
    e.textLabel?.text = ars[indexPath.item]
    return e
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 50000
}

func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {

    func RunLink(){
        if let v = c{
          98bdfe8daf6543d92"

在if语句中声明一个全新的变量link1,该变量仅存在于if语句中。改变

if arrayOfSorces[indexPath.item] == arrayOfSorces[0]{
    var link1 = "https://newsapi.org/v2/everything?sources=bbc-news&apiKey=a9ea5ee627044bd98bdfe8daf6543d92"
    RunLink()
}


(去掉创建新变量而不是更改现有变量中的值的
var

变量和范围的概念对于理解现代编程非常重要,您应该深入学习,直到真正理解它为止。
if arrayOfSorces[indexPath.item] == arrayOfSorces[0]{
   link1 = "https://newsapi.org/v2/everything?sources=bbc-news&apiKey=a9ea5ee627044bd98bdfe8daf6543d92"
    RunLink()
}