gpt4 book ai didi

objective-c - 知道如何在 DDTokenCache 中避免这种断言及其含义吗?

转载 作者:IT王子 更新时间:2023-10-29 07:53:09 25 4
gpt4 key购买 nike

我正在使用 NSDataDetectorNSTextCheckingTypeLink 在字符串中搜索链接(例如 https://stackoverflow.com/questions )。一般来说,它工作正常,但是当字符串包含某些非常长的链接(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 数据检测器上。

请检查 UIDataDetectorTypes:

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
};

如果您设置 UIDataDetectorTypeAll 或 UIDataDetectorTypeAddress 或 UIDataDetectorTypeCalendarEvent,那么 iOS 会在 iOS5.0 及更高版本上产生问题。

textview.dataDetectorTypes=UIDataDetectorTypeAll; 

或者

textview.dataDetectorTypes=UIDataDetectorTypeAddress | UIDataDetectorTypeCalendarEvent; 

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

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

textview.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber;

关于objective-c - 知道如何在 DDTokenCache 中避免这种断言及其含义吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4761357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com