使用ios4.x我可以使用下面的代码获取"kCTMessageReceivedNotification"通知时的消息
CTTelephonyCenterAddObserver( ct, NULL, callback,NULL,NULL, CFNotificationSuspensionBehaviorHold);
if ([notifyname isEqualToString:@"kCTMessageReceivedNotification"])//receive message
{
NSDictionary *info = (NSDictionary *)userInfo;
CFNumberRef msgID = (CFNumberRef)[info objectForKey:@"kCTMessageIdKey"];
int result;
CFNumberGetValue((CFNumberRef)msgID, kCFNumberSInt32Type, &result);
Class CTMessageCenter = NSClassFromString(@"CTMessageCenter");
id mc = [CTMessageCenter sharedMessageCenter];
id incMsg = [mc incomingMessageWithId: result];}
Run Code Online (Sandbox Code Playgroud)
但是对于ios5我不能这样做因为incMsg是零,所以我该怎么做才能得到消息?
谢谢
随着iOS 5的发布,我们在为sqlite数据库设置序列化选项时会遇到越来越多的错误(因此将其保存用于多线程).我们在sqlite3_config上收到SQLITE_MISUSE错误代码.有人注意到这种奇怪的行为吗?有人知道如何解决这个问题吗?它在之前的iOS版本上运行得非常好.
这是代码:
- (sqlite3 *)getNewDBConnection {
NSLog(@"sqlite3 lib version: %s", sqlite3_libversion());
//sqlite3_config() has to be called before any sqlite3_open calls.
if (sqlite3_threadsafe() > 0) {
int retCode = sqlite3_config(SQLITE_CONFIG_SERIALIZED);
if (retCode == SQLITE_OK) {
NSLog(@"Can now use sqlite on multiple threads, using the same connection");
} else {
NSLog(@"setting sqlite thread safe mode to serialized failed!!! return code: %d", retCode);
}
} else {
NSLog(@"Your SQLite database is not compiled to be threadsafe.");
}
sqlite3 *newDBconnection;
// Open the …Run Code Online (Sandbox Code Playgroud)