Xcode更新到6.3之后,NSFileTypeForHFSTypeCode报了三个错误,求助大神,怎么破

iOS 码拜 9年前 (2015-05-11) 1065次浏览 0个评论

Xcode更新到6.3之后,NSFileTypeForHFSTypeCode报了三个错误,求助大神,怎么破
这个问题要如何解决

60分
你有用 FMDB 吧?iOS 上不能用 NSFileTypeForHFSTypeCode,更新一下,新版加了编译器指令来判断:

#if TARGET_OS_MAC && !TARGET_OS_IPHONE
- (NSString*)applicationIDString {
    NSString *s = NSFileTypeForHFSTypeCode([self applicationID]);
    
    assert([s length] == 6);
    
    s = [s substringWithRange:NSMakeRange(1, 4)];
    
    
    return s;
    
}

- (void)setApplicationIDString:(NSString*)s {
    
    if ([s length] != 4) {
        NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
    }
    
    [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"""%@""", s])];
}


#endif
 #if TARGET_OS_MAC && !TARGET_OS_IPHONE
如果加了这个,那我之前的#if SQLITE_VERSION_NUMBER >= 3007017这个就会提示错误
如果把#if SQLITE_VERSION_NUMBER >= 3007017删掉,就正常了,但是数据显示不出来了。
引用 2 楼 Vampire521521 的回复:

 #if TARGET_OS_MAC && !TARGET_OS_IPHONE
如果加了这个,那我之前的#if SQLITE_VERSION_NUMBER >= 3007017这个就会提示错误
如果把#if SQLITE_VERSION_NUMBER >= 3007017删掉,就正常了,但是数据显示不出来了。

不要自己去改 FMDB 源码,更新一下 FMDB 的版本:

#if SQLITE_VERSION_NUMBER >= 3007017

- (uint32_t)applicationID {
    
    uint32_t r = 0;
    
    FMResultSet *rs = [self executeQuery:@"pragma application_id"];
    
    if ([rs next]) {
        r = (uint32_t)[rs longLongIntForColumnIndex:0];
    }
    
    [rs close];
    
    return r;
}

- (void)setApplicationID:(uint32_t)appID {
    NSString *query = [NSString stringWithFormat:@"pragma application_id=%d", appID];
    FMResultSet *rs = [self executeQuery:query];
    [rs next];
    [rs close];
}


#if TARGET_OS_MAC && !TARGET_OS_IPHONE
- (NSString*)applicationIDString {
    NSString *s = NSFileTypeForHFSTypeCode([self applicationID]);
    
    assert([s length] == 6);
    
    s = [s substringWithRange:NSMakeRange(1, 4)];
    
    
    return s;
    
}

- (void)setApplicationIDString:(NSString*)s {
    
    if ([s length] != 4) {
        NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
    }
    
    [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"""%@""", s])];
}


#endif

#endif
谢谢,解决了。
你好,我也遇到来同样饿问题,请问,代码加到哪个文件?
重新down一个新的FMDB替换
https://codeload.github.com/ccgus/fmdb/zip/master

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Xcode更新到6.3之后,NSFileTypeForHFSTypeCode报了三个错误,求助大神,怎么破
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!