Simple sorting of IOS Arrays

Source: Internet
Author: User
The array is roughly an object in it, which is sorted by a field date in the object, and displayed on tableview Online Based on the date size. Code

Array format: arry = [{Name: XXX, apply_date: 20121211}, {Name: XXX, apply_date: 20090815}, {Name: XXX, apply_date: 20111211}];

Nscomparisonresult compare (nsdictionary * firstdict, nsdictionary * seconddict, void * context) {If ([firstdict objectforkey: @ "apply_date"] integervalue] <[seconddict objectforkey: @ "apply_date"] integervalue]) return nsorderedascending; else if ([firstdict objectforkey: @ "apply_date"] integervalue]> [seconddict objectforkey: @ "apply_date"] integervalue]) return nsordereddescending; else return nsorderedsame ;}

Then we can call the above method to arrange it. Then we need to query the data in addition to the data and display it on the tablivew. We found a lot of duplicate data. The final reason is:

 
Nsstring * cellidentifier = [nsstring stringwithformat: @ "querycellid % d", indexpath. section, indexpath. row]; // nsstring * cellidentifier = @ "asdasdasdad"; <br> uitableviewcell * cell = [tableview dequeuereusablecellwithidentifier: cellidentifier];

we found that their indexpath needs to be added. row, indexpath. section, finally, we know that we need to [claimlist removeallobjects] before each query; after removing the array, we can make the query up-to-date. To sum up,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.