naga
naga

Reputation: 397

string append to array in swift

I am new to swift programming

after popover menu selecting am calling this function

   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()
       }

after service call Json Data is

enter image description here

I am display the the attendance = PRESENT attendance = ABSENT

but how to append the json data of

attendance = ""; to function of didSelectData

pls help me

Upvotes: 1

Views: 101

Answers (1)

Aravind A R
Aravind A R

Reputation: 2714

Try

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

}

Upvotes: 3

Related Questions