Sort the array of Dates in the Model iOS Swift


Sort the date array using for loop is not a great way.So we can use the below method to sort the array of dates
Code:
            let DateSorted = NSMutableArray(array:datearray.sortedArray(using: [NSSortDescriptor(key: "date", ascending: true)]))


The array model contains the key attribute named as the date.So we used the key value as date and sort using ascending order.

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift