Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多线程问题,有截图 #4

Open
meadlai opened this issue Dec 9, 2013 · 1 comment
Open

多线程问题,有截图 #4

meadlai opened this issue Dec 9, 2013 · 1 comment

Comments

@meadlai
Copy link

meadlai commented Dec 9, 2013

多个线程跑的时候,出现错误,不是每次都会出现.
截图如下:
error

方法里面出错.
(NSString *)getHanyuPinyinRecordFromCharWithChar:(unichar)ch {
int codePointOfChar = ch;
NSString *codepointHexStr =[[NSString stringWithFormat:@"%x", codePointOfChar] uppercaseString];
NSString *foundRecord =[self->_unicodeToHanyuPinyinTable objectForKey:codepointHexStr];
return [self isValidRecordWithNSString:foundRecord] ? foundRecord : nil;
}

@ghost
Copy link

ghost commented May 19, 2015

首先,感谢贡献这个代码的人,是你的辛勤汗水给我们开发了一个很不错的类库,节省了我们大量的时间和精力。然后,我发现了一个跟上面这位兄台一样的问题,我断点进去才发现原来这个对象不知道在哪里被释放了,由于这个resource这个类用的是单例对象,resource类本身不会在创建新的对象,所以导致这个_unicodeToHanyuPinyinTable对象一旦被释放就几乎是永远找不回来了(除非释放resource对象再创建新的对象),由于这个类用的是non-arc机制,所以后来我在_unicodeToHanyuPinyinTable这个类的初始化地方加了一个retain操作,就没有再报异常了,呵呵,虽然这个解决方案不一定好,但是总算可以跑起来了,分享给大家。对了,一定要记得在dealloc方法中吧_unicodeToHanyuPinyinTable这个释放,使用愉快😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant