0

I have a strange scenario, I have a list of events i have or going to attend. The list contains events in the past now and the future. Eventlist is sorted by date Now, I want to highlight a particular row where new event is added added with a border

For example event list is -

  1. event name - xxxxx, date - 25/08/2021
  2. event name - yyyyy, date - 26/08/2021
  3. event name - uuuu, date - 30/08/2021

No I want to add new event say for date 27 august and highlight that particular row

  1. event name - xxxxx, date - 25/08/2021
  2. event name - yyyyy, date - 26/08/2021
  3. event name - wwww, date - 27/08/2021
  4. event name - uuuu, date - 30/08/2021

Highlight the 3rd row in this case

Any suggestions and helps are appreciated. Please let me know if any clarification regarding question

  • 2
    Please show some code, a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – George Aug 27 '21 at 11:12
  • I guess you have an array of events, then compare them? Iterate over them and find when it's different? Do you only have "new/inserted events" to find? Or also deleted events? – Larme Aug 27 '21 at 11:13
  • Yes I have array of events. And I am able to add events to specific date. And I need to highlight the particular row to which the new events was added. @Larme – Sabaz Shereef Aug 27 '21 at 11:15
  • You needs to think first: Find new items in your array. Highlight it then. For the Highlight, i'd put it into the Model of your UITableView Datasource. Or in an array of new events id (if that's "quicker"). – Larme Aug 27 '21 at 11:17
  • @Larme How to find the new item in the array? – Sabaz Shereef Aug 27 '21 at 11:21
  • Maybe something there https://stackoverflow.com/questions/30685163/compare-2-arrays-and-list-the-differences-swift might be useful.. – Larme Aug 27 '21 at 11:24
  • *I am able to add events to specific date*. If so then you know the insertion index. Or at least you know the item. And likely there is a unique property to be able to identify the item in the array. – vadian Aug 27 '21 at 12:56

1 Answers1

-1
  • First add your whole server data in some NSMutableArray.
  • The compare your old server Date with new Date. Check like ( If your New date is lower then your old date so data will not insert in your NSMutableArray but if your date is Greater then your old Date so you insert that data after that index
Dishant Rajput
  • 1,329
  • 1
  • 10
  • 20