CoderJackyHuang / HYBUnicodeReadable

解决打印日志对于Unicode编码不能正常显示中文的问题,只需要将文件导入工程,不需要引用,就能达到打印日志显示Unicode编码中文数据
MIT License
355 stars 102 forks source link

新版1.2引入后会导致FMDB报错 #6

Open coolwxb opened 8 years ago

coolwxb commented 8 years ago

更新到1.2之后引起fmdb初始化错误,如果将库移除了fmdb初始化就正常了

错误日志: 2016-05-31 16:12:30.878 dituwuyou[661:200721] -DBModel init: /var/mobile/Containers/Data/Application/B95688FA-57B3-44DC-8148-750E39FDB8FC/Documents/dituwuyou.sqlite 2016-05-31 16:12:30.895 dituwuyou[661:200721] _path 2016-05-31 16:12:30.895 dituwuyou[661:200721] _queue 2016-05-31 16:12:30.895 dituwuyou[661:200721] _db 2016-05-31 16:12:30.895 dituwuyou[661:200721] -[FMDatabaseQueue db]: unrecognized selector sent to instance 0x12df5bcc0 2016-05-31 16:12:30.896 dituwuyou[661:200721] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FMDatabaseQueue db]: unrecognized selector sent to instance 0x12df5bcc0' * First throw call stack: (0x18201adb0 0x18167ff80 0x182021c4c 0x18201ebec 0x181f1cc5c 0x1005c6a58 0x1828fe3cc 0x181fe455c 0x181fe2464 0x1828fe320 0x1828fe1f0 0x1004850d8 0x1004852e0 0x100484ddc 0x100371240 0x10036e7f4 0x10038e864 0x1871ee9c0 0x18741e184 0x1874225f0 0x18741f764 0x1839bb7ac 0x1839bb618 0x1839bb9c8 0x181fd109c 0x181fd0b30 0x181fce830 0x181ef8c50 0x1871e794c 0x1871e2088 0x1004014b8 0x181a968b8) libc++abi.dylib: terminating with uncaught exception of type NSException

CoderJackyHuang commented 8 years ago

原则上与本库没有关系的。只是格式化一下打印而已啊!调用db做了些什么?代码放出来看看!

原始邮件 发件人:coolwxbnotifications@github.com 收件人:CoderJackyHuang/HYBUnicodeReadableHYBUnicodeReadable@noreply.github.com 发送时间:2016年5月31日(周二) 16:14 主题:[CoderJackyHuang/HYBUnicodeReadable] 新版1.2引入后会导致FMDB报错 (#6)

更新到1.2之后引起fmdb初始化错误,如果将库移除了fmdb初始化就正常了 错误日志: 2016-05-31 16:12:30.878 dituwuyou[661:200721] -DBModel init: /var/mobile/Containers/Data/Application/B95688FA-57B3-44DC-8148-750E39FDB8FC/Documents/dituwuyou.sqlite 2016-05-31 16:12:30.895 dituwuyou[661:200721] _path 2016-05-31 16:12:30.895 dituwuyou[661:200721] _queue 2016-05-31 16:12:30.895 dituwuyou[661:200721] _db 2016-05-31 16:12:30.895 dituwuyou[661:200721] -[FMDatabaseQueue db]: unrecognized selector sent to instance 0x12df5bcc0 2016-05-31 16:12:30.896 dituwuyou[661:200721] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FMDatabaseQueue db]: unrecognized selector sent to instance 0x12df5bcc0' * First throw call stack: (0x18201adb0 0x18167ff80 0x182021c4c 0x18201ebec 0x181f1cc5c 0x1005c6a58 0x1828fe3cc 0x181fe455c 0x181fe2464 0x1828fe320 0x1828fe1f0 0x1004850d8 0x1004852e0 0x100484ddc 0x100371240 0x10036e7f4 0x10038e864 0x1871ee9c0 0x18741e184 0x1874225f0 0x18741f764 0x1839bb7ac 0x1839bb618 0x1839bb9c8 0x181fd109c 0x181fd0b30 0x181fce830 0x181ef8c50 0x1871e794c 0x1871e2088 0x1004014b8 0x181a968b8) libc++abi.dylib: terminating with uncaught exception of type NSException — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

coolwxb commented 8 years ago
NSString* docsdir = [NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *dbpath = [docsdir stringByAppendingPathComponent:@"dituwuyou.sqlite"];
FMDatabaseQueue* queue   =[FMDatabaseQueue databaseQueueWithPath:dbpath];
 [queue inTransaction:^(FMDatabase *db, BOOL *rollback){
.....
}
coolwxb commented 8 years ago

到FMDB内部初始化就报错了

- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags vfs:(NSString *)vfsName {

    self = [super init];

    if (self != nil) {

        _db = [[[self class] databaseClass] databaseWithPath:aPath];
        FMDBRetain(_db);

#if SQLITE_VERSION_NUMBER >= 3005000
        BOOL success = [_db openWithFlags:openFlags vfs:vfsName];
#else
        BOOL success = [_db open];
#endif
        if (!success) {
            NSLog(@"Could not create database queue for path %@", aPath);
            FMDBRelease(self);
            return 0x00;
        }

        _path = FMDBReturnRetained(aPath);

/*************这句崩溃了***************/
        _queue = dispatch_queue_create([[NSString stringWithFormat:@"fmdb.%@", self] UTF8String], NULL);
/******************************/
        dispatch_queue_set_specific(_queue, kDispatchQueueSpecificKey, (__bridge void *)self, NULL);
        _openFlags = openFlags;
    }

    return self;
}
yuzhang2 commented 7 years ago

和self的description有关,如 NSLog(@"%@", self); 就会出错