close
Step1. create 一個xcode project, 這裏選擇single view即可.
Step2. 利用storyboard拉出你想要的介面
Step3. 在ViewController.h檔中宣告你要用的變數與方法(function)
Method : user所選擇的運算子
0 : user按下equal
1 : multiply
2 : divide
3 : subtract
4 : add
selectNumber為user鍵入的數字
runningTotal是為了存運算元
Step4. 將你宣告的變數和storyboard的button建立連結
點選整個使外框呈現藍色,選擇左邊的viewcontroller按鈕.
選擇欄位最右邊的箭頭
使用拖曳的方式拖拉到storyboard上對應的button或label等
Step4. 在ViewController.m檔中實作方法
基本上0~9的function都長一樣,只改變了第二行加的數字.
Screen.text 則是螢幕顯示的結果.
使用switch依照傳入的method去改變RunningTotal的值.
文章標籤
全站熱搜