Objective c 你知道如何在DDTokenCache中避免这个断言吗?它意味着什么?

Objective c 你知道如何在DDTokenCache中避免这个断言吗?它意味着什么?,objective-c,parsing,ios,assertion,Objective C,Parsing,Ios,Assertion,我正在使用NSDataDetector和NSTextCheckingTypeLink搜索字符串中的链接(例如)。一般来说,它可以正常工作,但当字符串包含某些非常长的链接(200+个字符)并后跟空格和另一个单词时,我得到以下断言: > DDRequire failed: the following assertion will only be logged once > > assertion on > /SourceCache/MobileDataDetectorsCo

我正在使用
NSDataDetector
NSTextCheckingTypeLink
搜索字符串中的链接(例如)。一般来说,它可以正常工作,但当字符串包含某些非常长的链接(200+个字符)并后跟空格和另一个单词时,我得到以下断言:

> DDRequire failed: the following assertion will only be logged once
> 
> assertion on
> /SourceCache/MobileDataDetectorsCore/MobileDataDetectorsCore-154/Sources/PushDown/DDTokenCache.c:310
> "delta >= 0" failed :Bad shift in
> DDTokenCacheMoveStreamOffset, aborting
这是导致以下情况的文本类型:

> blog.somethingorother.com/2011/storynameetcmorestuff/utm_source/eedburnerutmmediumfeedutmcampaign/FeedanutmcontentGooglFeedfetcherutmcampaign/FeedanutmcontentGooglFeedfetcher/eedburnerutm_mediumfeedutmcampaign/FeedanutmcontentGooglFeedfetcherutmcampaign HEY

是否有人知道这背后的原因或对此有任何其他见解?

您可以对文本进行预处理,替换那些造成麻烦的链接。

已解决:问题在于UITextView数据检测器。

textview.dataDetectorTypes=UIDataDetectorTypeAll; 
请检查UIDataDetectTypes:

typedef NS_OPTIONS(NSUInteger, UIDataDetectorTypes) {
UIDataDetectorTypePhoneNumber   = 1 << 0,          // Phone number detection
UIDataDetectorTypeLink          = 1 << 1,          // URL detection    
#if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIDataDetectorTypeAddress       = 1 << 2,          // Street address detection
UIDataDetectorTypeCalendarEvent = 1 << 3,          // Event detection
#endif    

UIDataDetectorTypeNone          = 0,               // No detection at all
UIDataDetectorTypeAll           = NSUIntegerMax    // All types
};

有时它会在iOS5.0及更高版本上产生问题

因此您需要明确设置数据检测器:

textview.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber;

您应该将此信息与复制此问题的示例项目一起归档。好的,可以。但我仍然希望有一个解决办法,不涉及废除NSDataDetector。对于其他运行此功能的人来说:它是以问题ID 8917104提交给苹果的。你可以在你的bug报告中引用它,如果你做了一个的话。闻起来像框架bug。你可以尝试插入一个#或?在_space _heydown投票者之前的链接后面--请解释。这听起来像是一个有效的解决办法:)
textview.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber;