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

时间:2018-10-25 18:37:08

标签: swift swift2

我正面临的问题是我无法更新变量lin。我已经尝试过复数f :)。要到达代码中的relevode快速第二行,请在该处标识变量,然后,如果u滚动至代码底部,则该变量应该更改但不会更改

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"

1 个答案:

答案 0 :(得分:1)

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

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

收件人

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

(摆脱var。这将创建一个新变量,而不是更改现有变量中的值。)