| tags:littlist objective-c develop categories:iapp

Reminder:日時の書き込み

リマインダーへの日時の書き込み

読み込み時には

event.dueDate = eventToRead.dueDateComponents.date;
event.timeZone = eventToRead.dueDateComponents.timeZone;

と、あっさりと行くのですが、.dueDateComponents.date は readonly で書き込み時には日時をバラバラにしてまとめて書き込みます。


  NSCalendar *gregorian = [[NSCalendar alloc]
                           initWithCalendarIdentifier:NSGregorianCalendar];
  unsigned unitFlags= NSYearCalendarUnit|NSMonthCalendarUnit | NSDayCalendarUnit |
   NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit |NSTimeZoneCalendarUnit;
  
  NSDateComponents *dailyComponents=[gregorian components:unitFlags fromDate:eventToExport.dueDate];
  
  eventToWrite.dueDateComponents = dailyComponents;
  eventToWrite.timeZone = eventToExport.timeZone;
  

See Also

🏝 tipping

🌷 sat ⚡️ goozenlab@getalby.com
🌻 bitcoin : bc1qnjhnsxgqah050995dkdveav4y3t3d7uxyme4ud

If you do send a tip, Please email me so that I can say thank you.