Hi I am trying to figure out how to delete a CKRecord (Cloud Kit) from a table programmatically in my app. However, I need to be able to delete the earliest record only when I have over 1000 records in the table. So when a new record is entered, it will check if there are over 1000 records in the table and if there is, it will delete the earliest record submitted. Please help!

Heres my code:

                    for record in records {


                        let moodRecord:CKRecord = record as! CKRecord
                        self.moodArray.append(moodRecord.objectForKey("Color") as! String)

                        if recordNumber > 1000 {

                            // DELETE RECORD HERE

                        }

                        recordNumber++

                    }

Related posts

Recent Viewed