从iOS9开始,本地通知无法正常工作.有时用户会收到通知,有时他们却没有收到通知.我的通知每天重复.知道可能导致问题的原因吗?我看到一些帖子,iOS9中有一个错误,但我不确定是什么原因.
这是一段代码:
NSDate *alarmDate = [date dateByAddingTimeInterval:DEFAULT_SNOOZE_DURATION * i];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = alarmDate;
localNotif.timeZone = nil;
localNotif.alertBody = alertBody;
localNotif.hasAction = YES;
localNotif.applicationIconBadgeNumber = 1;
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.repeatInterval = NSCalendarUnitDay;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif]
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助
我正在使用Hibernate作为我的ORM层.我试图在一个事务中运行一批HQL查询(我不能使用session.update).问题是即使transaction.commit()在循环结束时,更新查询也会逐个运行.有没有办法在一个事务中运行多个HQL查询?
public void updateItems() {
t = session.beginTransaction();
for (int i = 0; i < itemList.size(); i++) {
Query q = createUpdateQuery(session, itemList.get(i));
q.executeUpdate(); //updating one by one, and not waiting for transaction commit
}
t.commit();
}
Query createUpdateQuery(Session session, Item item) {
Query q = session.createQuery(
"Update Item i set i.notes=:notes, i.time=:time, i.counter=:counter, i.status=:status Where i.id=:id and i.time=:time");
q.setParameter("time", item.getTime());
q.setParameter("status", item.getStatus());
q.setParameter("notes", item.getNotes());
q.setParameter("id", item.getId());
return q;
}
Run Code Online (Sandbox Code Playgroud)
感谢任何帮助.
我已经为我的目标添加了-com.apple.CoreData.ConcurrencyDebug 1标志.问题是我有一个正在运行的后台块,当我使用NSPrivateQueueConcurrencyType或NSMainQueueConcurrencyType时崩溃
我的代码:
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSManagedObjectContext *privateManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[privateManagedObjectContext setParentContext:_mainContext];
[User fetchUserWithContext:_ privateManagedObjectContext];
}];
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[User fetchUserWithContext:_mainContext];
}];
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我得到:
CoreData` + [NSManagedObjectContext Multithreading_Violation_AllThatIsLeftToUsIsHonor ]:
谢谢你的帮助,
concurrency ×1
core-data ×1
hibernate ×1
ios ×1
ios9 ×1
java ×1
jdbc ×1
mysql ×1
objective-c ×1