我不明白为什么这个 NSInteger 计数器会增加到数据库行真实值的 4 倍。也许这很愚蠢,但我真的不明白......
到目前为止谢谢:)
NSInteger *i;
i = 0;
for ( NSDictionary *teil in gText ) {
//NSLog(@"%@", [teil valueForKey:@"Inhalt"]);
[databaseWrapper addEntry:[teil valueForKey:@"Inhalt"] withTyp:[teil valueForKey:@"Typ"] withParagraph:[teil valueForKey:@"Paragraph"]];
i+=1;
}
NSLog(@"Number of rows created: %d", i);
因为 i 是一个指针,并且您正在递增指针值,该值很可能以 4 为步长(NSInteger 指针的大小)。只要删除指针 * 引用就可以了。
NSInteger i = 0;
for ( NSDictionary *teil in gText ) {
理论上你可以用困难的方式做到这一点。
NSInteger *i;
*i = 0;
for ( NSDictionary *teil in gText ) {
...
*i = *i + 1;
...
From:
基础数据类型参考
#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
#else
typedef int NSInteger;
#endif
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)