字符串附加到swift中的数组

时间:2017-07-24 08:45:07

标签: arrays swift swift3

我是swift编程的新手

弹出菜单选择调用此功能后

   func didSelectData(_ result: String){

    self.attendanceInfo.removeAll()
        if(result == "All Student"){
            self.attendanceInfo = self.attendanceInfoDupilicate
        }
        else if(result == "Present Student" ){
            self.attendanceInfo.removeAll()
            let itemsarray = self.attendanceInfoDupilicate
            for AttendanceInfo in itemsarray {
                if(AttendanceInfo.attendance.range(of: "PRESENT", options: .caseInsensitive) != nil){
                    self.attendanceInfo.append(AttendanceInfo)
                }
            }
        } else{
            self.attendanceInfo.removeAll()
            let itemsarray = self.attendanceInfoDupilicate
            for AttendanceInfo in itemsarray {
                if(AttendanceInfo.attendance.range(of: "ABSENT", options: .caseInsensitive) != nil){
                    self.attendanceInfo.append(AttendanceInfo)
===========>.  I have to append the  attendance = ""; to AttendanceInfo  
                } 
            }
        }
        self.TableView.reloadData()
       }
服务调用Json Data后

enter image description here

我正在显示 出勤=现在 出勤率=缺席

但如何附加

的json数据

出勤=“”;功能的didSelectData

请帮帮我

1 个答案:

答案 0 :(得分:3)

尝试

if (AttendanceInfo.attendance.range(of: "ABSENT", options: .caseInsensitive) != nil) || AttendanceInfo.attendance.isEmpty {

}