Arrays 在Swift中的switch/case函数中使用数组
我正在尝试将选择器视图添加到我现有的应用程序中。然而,我遇到了一个障碍。我对Swift还是新手,我不知道该如何描述这一点,但希望您能充分理解以下内容,提出适当的问题来解决这一问题 我收到的错误消息是以下行中的“致命错误:索引超出范围”:Arrays 在Swift中的switch/case函数中使用数组,arrays,swift,uitableview,Arrays,Swift,Uitableview,我正在尝试将选择器视图添加到我现有的应用程序中。然而,我遇到了一个障碍。我对Swift还是新手,我不知道该如何描述这一点,但希望您能充分理解以下内容,提出适当的问题来解决这一问题 我收到的错误消息是以下行中的“致命错误:索引超出范围”: cell.txtField_PickData.text = self.arrayTemprature[indexPath.row].valueForKey("tempValue") as? String MyTitlery等于两个输入“空气温度”或“水温” 下
cell.txtField_PickData.text = self.arrayTemprature[indexPath.row].valueForKey("tempValue") as? String
MyTitlery等于两个输入“空气温度”或“水温”
下面是关于此错误的代码部分。如果需要更多代码来帮助识别问题,请乐于提供:
import UIKit
class DiveDetailsViewController: UITableViewController, LocationDelegate, ItemDataSelectedProtocol, UITextFieldDelegate , UIPickerViewDataSource , UIPickerViewDelegate
{
let numberOfComponents: Int = 2
let temperatureComponentRows: Int = 131
let temperatureSymbolComponentRows: Int = 2
let Fahrenheit: String = "F"
let Celsius: String = "C"
let minDegrees = -10
let maxDegrees = 120
private var degrees = [Int]()
var temperature: Int = 26 // our default temperature
var temperatureType: String = "C" // our default type is Farenheit
// let myTitleArray = ["Air temperature" , "Water temperature"]
var pickerView : UIPickerView!
var pickerViewFarCel : UIPickerView!
var dictTemprature = [String : String]()
var arrayTemprature = [AnyObject]()
var tempIndex = 0
var tempSymbolIndex = 0
var arraySymbol = ["C" , "F"]
var tempratureOfAir : String = ""
var tempratureOfWater : String = ""
private typealias ItemDefaults = [ItemTypes : String]
private let NumberOfSections: Int = 7
private let NumberOfRowsInSection0: Int = 2
private let NumberOfRowsInSection1: Int = 7
private let NumberOfRowsInSection2: Int = 4
private let NumberOfRowsInSection3: Int = 6
private let NumberOfRowsInSection4: Int = 3
private let NumberOfRowsInSection5: Int = 4
private let NumberOfRowsInSection6: Int = 1
//
// Section 0 Cells
//
private let DiveNumberIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 0)
private let DiveNameIndex: NSIndexPath = NSIndexPath(forRow: 1, inSection: 0)
// Section 1 Cells
private let DiveWaterIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 1)
private let DiveVisibilityIndex: NSIndexPath = NSIndexPath(forRow: 1, inSection: 1)
private let DiveCurrentsIndex: NSIndexPath = NSIndexPath(forRow: 2, inSection: 1)
private let AirTempPickerIndex: NSIndexPath = NSIndexPath(forRow: 3, inSection: 1)
private let WaterTempPickerIndex: NSIndexPath = NSIndexPath(forRow: 4, inSection: 1)
private let DiveWeatherIndex: NSIndexPath = NSIndexPath(forRow: 5, inSection: 1)
private let DiveSurfaceIndex: NSIndexPath = NSIndexPath(forRow: 6, inSection: 1)
// Section 2 Cells
private let DiveLocationIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 2)
private let DiveBodyOfWaterIndex: NSIndexPath = NSIndexPath(forRow: 1, inSection: 2)
private let DiveCityIndex: NSIndexPath = NSIndexPath(forRow: 2, inSection: 2)
private let DiveCountryIndex: NSIndexPath = NSIndexPath(forRow: 3, inSection: 2)
// Section 3 Cells
private let DiveCircuitIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 3)
private let DiveStartingPressureIndex: NSIndexPath = NSIndexPath(forRow: 1, inSection: 3)
private let DiveEndingPressureIndex: NSIndexPath = NSIndexPath(forRow: 2, inSection: 3)
private let DiveWeightIndex: NSIndexPath = NSIndexPath(forRow: 3, inSection: 3)
private let DiveDiveSuitIndex: NSIndexPath = NSIndexPath(forRow: 4, inSection: 3)
private let DiveEquipmentIndex: NSIndexPath = NSIndexPath(forRow: 5, inSection: 3)
// Section 4 Cells
private let DiveEntryTypeIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 4)
private let DiveDiveTypeIndex: NSIndexPath = NSIndexPath(forRow: 1, inSection: 4)
private let DiveRatingIndex: NSIndexPath = NSIndexPath(forRow: 2, inSection: 4)
// Section 5 Cells
private let DiveDiveMasterIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 5)
private let DiveDiveBoatOperatorIndex: NSIndexPath = NSIndexPath(forRow: 1, inSection: 5)
private let DiveDiveCenterIndex: NSIndexPath = NSIndexPath(forRow: 2, inSection: 5)
private let DiveTripOperatorIndex: NSIndexPath = NSIndexPath(forRow: 3, inSection: 5)
// Section 6 Cells
private let DiveNotesIndex: NSIndexPath = NSIndexPath(forRow: 0, inSection: 6)
private let location: Location = Location()
private var isSelected: Bool = false
private var defaultValues: ItemDefaults = ItemDefaults()
private var selectedItemType: ItemTypes = ItemTypes.None
private var longitude: Double = 0.0
private var latitude: Double = 0.0
var diveModel: DiveModel = DiveModel()
override func viewDidLoad()
{
super.viewDidLoad()
// Array of the Degree :
for i in self.minDegrees ..< self.maxDegrees+1{
self.degrees.append(i)
}
print(self.degrees)
// Array of Table
self.dictTemprature = ["tempValue" : "" , "tempSymbol" : ""]
arrayTemprature = [self.dictTemprature , self.dictTemprature]
print(arrayTemprature)
print(self.arrayTemprature[0].valueForKey("tempValue"))
//
self.registerCustomTableViewCells()
self.defaultValues = self.getDefaultValues()
print(self.diveModel)
}
override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)
location.delegate = self
location.start()
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell: UITableViewCell!
switch indexPath
{
case DiveNumberIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveNumberCell)
(cell as! DiveNumberTableViewCell).textField.placeholder = Strings.DiveNumber.localized
//I realize this will be autoentered, but needs to be displayed
case DiveNameIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveSiteCell)
(cell as! DiveSiteTableViewCell).textField.placeholder = Strings.Name.localized
//This will need to be the data entered from the previous screen and not editable
case AirTempPickerIndex:
let cell : AirTemperatureTableViewCell = tableView.dequeueReusableCellWithIdentifier("AirTemperatureCell", forIndexPath: indexPath) as! AirTemperatureTableViewCell
cell.txtField_PickData.tag = indexPath.row
cell.textField_TempSymbol.tag = indexPath.row
cell.txtField_PickData.placeholder = "Air"
cell.textField_TempSymbol.placeholder = ""
cell.txtField_PickData.text = self.arrayTemprature[indexPath.row].valueForKey("tempValue") as? String
cell.textField_TempSymbol.text = self.arrayTemprature[indexPath.row].valueForKey("tempSymbol") as? String
return cell
case WaterTempPickerIndex:
let cell : WaterTemperatureTableViewCell = tableView.dequeueReusableCellWithIdentifier("WaterTemperatureCell", forIndexPath: indexPath) as! WaterTemperatureTableViewCell
cell.txtField_PickData.tag = indexPath.row
cell.textField_TempSymbol.tag = indexPath.row
cell.txtField_PickData.placeholder = "Water"
cell.textField_TempSymbol.placeholder = ""
cell.txtField_PickData.text = self.arrayTemprature[indexPath.row].valueForKey("tempValue") as? String
cell.textField_TempSymbol.text = self.arrayTemprature[indexPath.row].valueForKey("tempSymbol") as? String
return cell
case DiveLocationIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.LocationCell)
cell.textLabel!.text = Strings.Location.localized
cell.detailTextLabel!.text = String(format: "%f, %f", self.latitude, self.longitude)
case DiveWeatherIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Weather.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.Weather]
case DiveVisibilityIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Visibility.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.Visibility]
case DiveEntryTypeIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.EntryType.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.EntryType]
case DiveWaterIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Water.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.Water]
case DiveDiveSuitIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.DiveSuit.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.DiveSuit]
case DiveNotesIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveNoteCell)
case DiveRatingIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Rating.localized
cell.detailTextLabel!.text = ""
case DiveCurrentsIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Currents.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.Currents]
case DiveSurfaceIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Surface.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.Surface]
case DiveBodyOfWaterIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.BodyOfWater.localized
cell.detailTextLabel!.text = ""
case DiveCityIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.City.localized
cell.detailTextLabel!.text = ""
case DiveCountryIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Country.localized
cell.detailTextLabel!.text = ""
case DiveCircuitIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Circuit.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.Circuit]
case DiveStartingPressureIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.StartingTankUsageCell)
(cell as! StartingTankUsageCell).startingPressureTextField.placeholder = Strings.Start.localized
case DiveEndingPressureIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.EndingTankUsageCell)
(cell as! EndingTankUsageCell).textField.placeholder = Strings.Finish.localized
case DiveDiveMasterIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.DiveMaster.localized
cell.detailTextLabel!.text = ""
case DiveWeightIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.WeightsCell)
(cell as! WeightsTableViewCell).textField.placeholder = Strings.Weight.localized
case DiveEquipmentIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.Equipment.localized
cell.detailTextLabel!.text = ""
case DiveDiveTypeIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.DiveType.localized
cell.detailTextLabel!.text = self.defaultValues[ItemTypes.DiveType]
case DiveDiveBoatOperatorIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.BoatOperator.localized
cell.detailTextLabel!.text = ""
case DiveDiveCenterIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.DiveCenter.localized
cell.detailTextLabel!.text = ""
case DiveTripOperatorIndex:
cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveItemCell)
cell.textLabel!.text = Strings.TripOperator.localized
cell.detailTextLabel!.text = ""
default:
cell = nil
}
return cell
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int
{
return self.NumberOfSections
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
if section == 0
{
return self.NumberOfRowsInSection0
}
else if section == 1
{
return self.NumberOfRowsInSection1
}
else if section == 2
{
return self.NumberOfRowsInSection2
}
else if section == 3
{
return self.NumberOfRowsInSection3
}
else if section == 4
{
return self.NumberOfRowsInSection4
}
else if section == 5
{
return self.NumberOfRowsInSection5
}
else if section == 6
{
return self.NumberOfRowsInSection6
}
else
{
return 0
}
}
override func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath?
{
//
// It the row that is going to be selected is of an item type, then we save off the
// selectedItemType so it can be used during the segue.
//
switch indexPath
{
case DiveWeatherIndex:
self.selectedItemType = ItemTypes.Weather
case DiveVisibilityIndex:
self.selectedItemType = ItemTypes.Visibility
case DiveEntryTypeIndex:
self.selectedItemType = ItemTypes.EntryType
case DiveWaterIndex:
self.selectedItemType = ItemTypes.Water
case DiveDiveSuitIndex:
self.selectedItemType = ItemTypes.DiveSuit
case DiveDiveTypeIndex:
self.selectedItemType = ItemTypes.DiveType
case DiveCurrentsIndex:
self.selectedItemType = ItemTypes.Currents
case DiveSurfaceIndex:
self.selectedItemType = ItemTypes.Surface
case DiveCircuitIndex:
self.selectedItemType = ItemTypes.Circuit
default:
self.selectedItemType = ItemTypes.None
}
return indexPath
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
let cell = tableView.cellForRowAtIndexPath(indexPath)
if cell is DiveEditTableViewCell
{
(cell as! DiveEditTableViewCell).textField.userInteractionEnabled = true
(cell as! DiveEditTableViewCell).textField.becomeFirstResponder()
}
else if cell is DiveNoteTableViewCell
{
(cell as! DiveNoteTableViewCell).textView.userInteractionEnabled = true
(cell as! DiveNoteTableViewCell).textView.becomeFirstResponder()
}
else if cell is StartingTankUsageCell
{
(cell as! StartingTankUsageCell).startingPressureTextField.userInteractionEnabled = true
(cell as! StartingTankUsageCell).startingPressureTextField.becomeFirstResponder()
}
else if cell is EndingTankUsageCell
{
(cell as! EndingTankUsageCell).textField.userInteractionEnabled = true
(cell as! EndingTankUsageCell).textField.becomeFirstResponder()
}
else if cell is WeightsTableViewCell
{
(cell as! WeightsTableViewCell).textField.userInteractionEnabled = true
(cell as! WeightsTableViewCell).textField.becomeFirstResponder()
}
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
{
let cell = tableView.cellForRowAtIndexPath(indexPath)
if cell is DiveEditTableViewCell
{
(cell as! DiveEditTableViewCell).textField.userInteractionEnabled = false
(cell as! DiveEditTableViewCell).textField.resignFirstResponder()
}
else if cell is DiveNoteTableViewCell
{
(cell as! DiveNoteTableViewCell).textView.userInteractionEnabled = false
(cell as! DiveNoteTableViewCell).textView.resignFirstResponder()
}
else if cell is StartingTankUsageCell
{
(cell as! StartingTankUsageCell).startingPressureTextField.userInteractionEnabled = false
(cell as! StartingTankUsageCell).startingPressureTextField.becomeFirstResponder()
}
else if cell is EndingTankUsageCell
{
(cell as! EndingTankUsageCell).textField.userInteractionEnabled = false
(cell as! EndingTankUsageCell).textField.becomeFirstResponder()
}
else if cell is WeightsTableViewCell
{
(cell as! WeightsTableViewCell).textField.userInteractionEnabled = false
(cell as! WeightsTableViewCell).textField.becomeFirstResponder()
}
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
var height = tableView.rowHeight
if indexPath == self.DiveNotesIndex
{
let cell = tableView.dequeueReusableCellWithIdentifier(Resource.DiveNoteCell)
height = CGFloat((cell?.bounds.size.height)!)
}
return height
}
func fahToCel(tempInF:Double) ->Double {
let celsius = (tempInF - 32.0) * (5.0/9.0)
return celsius as Double
}
func celToFah(tempInC:Double) ->Double {
let fahrenheit = (tempInC * 9.0/5.0) + 32.0
return fahrenheit as Double
}
func pickerFarCal(textField : UITextField){
self.tempSymbolIndex = 0
pickerViewFarCel = UIPickerView(frame:CGRectMake(0, 0, self.view.frame.size.width, 216))
pickerViewFarCel.delegate = self
pickerViewFarCel.dataSource = self
pickerViewFarCel.backgroundColor = UIColor.whiteColor()
textField.inputView = pickerViewFarCel
pickerViewFarCel.tag = textField.tag
let toolBar = UIToolbar()
toolBar.barStyle = .Default
toolBar.translucent = true
toolBar.tintColor = UIColor(red: 92/255, green: 216/255, blue: 255/255, alpha: 1)
toolBar.sizeToFit()
// Adds the buttons
let doneButton = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: #selector(DiveDetailsViewController.doneClickSymbol))
let spaceButton = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Cancel", style: .Plain, target: self, action: #selector(DiveDetailsViewController.cancelClickSymbol))
toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)
toolBar.userInteractionEnabled = true
textField.inputAccessoryView = toolBar
}
func doneClickSymbol(){
self.view.endEditing(true)
print(self.arraySymbol[tempSymbolIndex])
if self.arrayTemprature[pickerViewFarCel.tag].valueForKey("tempValue") as! String == ""{
print("Not Convert")
}else if self.arrayTemprature[pickerViewFarCel.tag].valueForKey("tempSymbol") as! String == self.arraySymbol[tempSymbolIndex]{
print("Not Convert")
}else{
print("Convert")
if self.arraySymbol[tempSymbolIndex] == "C"{
let value = Double(self.arrayTemprature[pickerViewFarCel.tag].valueForKey("tempValue") as! String)
let convertedValue = self.fahToCel(value!)
let myValue = String(format: "%.1f", convertedValue)
self.dictTemprature["tempValue"] = myValue
self.dictTemprature["tempSymbol"] = self.arraySymbol[tempSymbolIndex]
}else{
let value = Double(self.arrayTemprature[pickerViewFarCel.tag].valueForKey("tempValue") as! String)
let convertedValue = self.celToFah(value!)
let myValue = String(format: "%.1f", convertedValue)
self.dictTemprature["tempValue"] = myValue
self.dictTemprature["tempSymbol"] = self.arraySymbol[tempSymbolIndex]
}
self.arrayTemprature[pickerViewFarCel.tag] = self.dictTemprature
tableView.reloadData()
}
}
func cancelClickSymbol(){
self.view.endEditing(true)
}
// PickerView
func pickerViewTemprature(textField : UITextField){
// Index
self.tempSymbolIndex = 0
self.tempIndex = 276
pickerView = UIPickerView(frame:CGRectMake(0, 0, self.view.frame.size.width, 216))
pickerView.delegate = self
pickerView.dataSource = self
pickerView.backgroundColor = UIColor.whiteColor()
textField.inputView = pickerView
pickerView.tag = textField.tag
pickerView.selectRow(276, inComponent: 0, animated: true)
let toolBar = UIToolbar()
toolBar.barStyle = .Default
toolBar.translucent = true
toolBar.tintColor = UIColor(red: 92/255, green: 216/255, blue: 255/255, alpha: 1)
toolBar.sizeToFit()
// Adds the buttons
let doneButton = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: #selector(DiveDetailsViewController.doneClickMaterial))
let spaceButton = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Cancel", style: .Plain, target: self, action: #selector(DiveDetailsViewController.cancelClickMaterial))
toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)
toolBar.userInteractionEnabled = true
textField.inputAccessoryView = toolBar
}
func doneClickMaterial(){
self.view.endEditing(true)
self.dictTemprature["tempValue"] = "\(self.degrees[tempIndex])"
self.dictTemprature["tempSymbol"] = self.arraySymbol[tempSymbolIndex]
self.arrayTemprature[pickerView.tag] = self.dictTemprature
self.tableView.reloadData()
}
func cancelClickMaterial(){
self.view.endEditing(true)
}
// MARK: delegate
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
if (pickerViewFarCel != nil){
return 1
}else{
return 2
}
}
func pickerView(pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat{
return 100
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if (pickerViewFarCel != nil){
return self.temperatureSymbolComponentRows
}else{
if component == 0{
return self.degrees.count
}
else{
return self.temperatureSymbolComponentRows
}
}
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if (pickerViewFarCel != nil){
return self.arraySymbol[row]
}else{
if component == 0 {
return "\(self.degrees[row])"
} else {
return self.arraySymbol[row]
}
}
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if (pickerViewFarCel != nil){
tempSymbolIndex = row
}else{
if component == 0 {
tempIndex = row
} else {
tempSymbolIndex = row
}
}
}
导入UIKit
类dividetailsviewcontroller:UITableViewController、LocationDelegate、ItemDataSelectedProtocol、UIExtFieldDelegate、UIPickServiceWdataSource、UIPickServiceWdelegate
{
设numberOfComponents:Int=2
设温度组件行:Int=131
设温度SYMBOLComponentRows:Int=2
让华氏温度:String=“F”
设为:String=“C”
让minDegrees=-10
设maxDegrees=120
私有变量度=[Int]()
变量温度:Int=26//我们的默认温度
var temperatureType:String=“C”//我们的默认类型是Farenheit
//让myTitleArray=[“气温”、“水温”]
var pickerView:UIPickerView!
var pickerViewFarCel:UIPickerView!
var dictTemprature=[String:String]()
var arrayTemprature=[AnyObject]()
var tempIndex=0
变量tempsymonendex=0
var arraySymbol=[“C”,“F”]
var tempratureOfAir:String=“”
var tempratureOfWater:String=“”
私有类型别名ItemDefaults=[ItemTypes:String]
私人出租数量:Int=7
私有出租编号行第0节:Int=2
第1节中的私有出租编号:Int=7
第2节中的私有出租编号:Int=4
私人出租编号第3节:Int=6
第4节中的私有出租编号:Int=3
第5节中的私有出租编号:Int=4
第6节中的私有出租编号:Int=1
//
//第0节单元格
//
私有let DiveNumberIndex:NSIndexPath=NSIndexPath(forRow:0,第0节)
私有let DiveNameIndex:nsindepath=nsindepath(forRow:1,第0节)
//第一节细胞
私有let DiveWaterIndex:NSIndexPath=NSIndexPath(forRow:0,第1节)
private let DiveVisibilityIndex:nsindepath=nsindepath(forRow:1,第1节)
私有let divecurentsindex:nsindepath=nsindepath(forRow:2,第1节)
私有let AirTempPickerIndex:nsindepath=nsindepath(forRow:3,第1节)
私有let WaterTempPickerIndex:NSIndexPath=NSIndexPath(forRow:4,第1节)
private let DiveWeatherIndex:nsindepath=nsindepath(forRow:5,第1节)
private-let-desurfaceindex:nsindepath=nsindepath(forRow:6,第1节)
//第2节细胞
私有let DiveLocationIndex:nsindepath=nsindepath(forRow:0,第2节)
私有let DiveBodyOfWaterIndex:NSIndexPath=NSIndexPath(forRow:1,第2节)
私有let DiveCityIndex:nsindepath=nsindepath(forRow:2,第2节)
私有let diveConCountryIndex:NSIndexPath=NSIndexPath(forRow:3,第2节)
//第3节细胞
私有let divecircitindex:nsindepath=nsindepath(forRow:0,第3节)
private-let-divertingpressureIndex:nsindepath=nsindepath(forRow:1,第3节)
私有let diveedingPressureIndex:NSIndexPath=NSIndexPath(forRow:2,第3节)
私有let-DiveWeightIndex:NSIndexPath=NSIndexPath(forRow:3,第3节)
私有let-divedivesuiteindex:nsindepath=nsindepath(forRow:4,第3节)
私有let-DiveEquipmentIndex:nsindepath=nsindepath(forRow:5,第3节)
//第4节单元格
私有let DiveEntryTypeIndex:nsindepath=nsindepath(forRow:0,第4节)
私有let-DiveDiveTypeIndex:nsindepath=nsindepath(forRow:1,第4节)
私有let divatingindex:nsindepath=nsindepath(forRow:2,第4节)
//第5节单元格
私有let-DiveDiveMasterIndex:nsindepath=nsindepath(forRow:0,第5节)
私有let-DiveDiveBoatOperatorIndex:NSIndexPath=NSIndexPath(forRow:1,第5节)
私有let DiveDiveCenterIndex:nsindepath=nsindepath(forRow:2,第5节)
私有let DiveTripOperatorIndex:nsindepath=nsindepath(forRow:3,第5节)
//第6节单元格
私有let DiveNotesIndex:nsindepath=nsindepath(forRow:0,第6节)
私有出租位置:位置=位置()
private var isSelected:Bool=false
private-var-defaultValues:ItemDefaults=ItemDefaults()
私有变量selectedItemType:ItemTypes=ItemTypes.None
私有变量经度:双精度=0.0
专用变量纬度:双=0.0
var diveModel:diveModel=diveModel()
重写func viewDidLoad()
{
super.viewDidLoad()
//学位的数组:
对于self.minDegrees中的i.func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let count = self. myTitleArray?.count as Int {
return (count)
} else {
//myTitleArray is nil, so just return 0
return 0
}
}
private let NumberOfRowsInSection1: Int = 5