0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

swift 整数値 Int() と 配列 Array() の抽出

Last updated at Posted at 2021-11-24

Intは整数値を定義するのに用い、Arrayは配列を組織する。

class ViewController: UIViewController {
var c = Int()
var elem = NSArray()
  override func viewDidLoad(){
    elem = [ 
      “Name1”, “name2”, “name3”, “name4”
    ]
    var btn1 = UIButton()
    btn1.addTarget(self, action: #selector(button1(button1:)), for: .touchUpInside)
  }
  @objc func button1(button1: UIButton){
    C += 1
    Object()
  }    
  Object(){
   if(c <= elem.count - 1){
      let name = elem[c]
    } else {
      let name = elem[0]
    }
    let label = UILabel()
    label.text = String(name)
  }
}

上の文字列は、ボタンを押すたび、に配列に置かれた、名前が変わり、ラベルに表示されることを記している。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?