【问题标题】:How to Predicate userinfo.key in UILocalNotification如何在 UILocalNotification 中断言 userinfo.key
【发布时间】:2014-03-04 10:53:31
【问题描述】:

  • 在我的应用程序中用户设置了工作日要做的任务列表。所以我 当用户打开应用程序时,我会在每个星期五重新安排每个任务。所以 我想知道剩下的通知列表。
  • 所以 我需要什么想要断言 Timeid 或工作日从 “ScheduleArray”。

【问题讨论】:

  • 您是否尝试使用谓词过滤您的数组?它以前如何?出了什么问题?
  • int Timeid = [[notification.userInfo valueForKey:@"Timeid"]integerValue];
  • 我知道如何获取 Timeid 但不知道如何将它与 Predicate 一起使用。

标签: ios iphone nspredicate uilocalnotification predicate


【解决方案1】:

只需使用:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"userInfo.WeekDay = %d", yourWeekDay];

或:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"userInfo.Timeid = %d", yourTimeID];

然后:

NSArray *notifications = [[[UIApplication sharedApplication] scheduledLocalNotifications] filteredArrayUsingPredicate:predicate];

【讨论】:

  • 我得到 0 个对象
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-15
相关资源
最近更新 更多