I am using NSDataDetector
with NSTextCheckingTypeLink
to search a string for links (e.g. https://stackoverflow.com/questions) within it. Generally, it works fine, but when the string contains certain very long links (200+ chars) followed by a space and another word, I get this assertion:
> 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
This is the kind of text that causes this:
> blog.somethingorother.com/2011/storynameetcmorestuff/utm_source/eedburnerutmmediumfeedutmcampaign/FeedanutmcontentGooglFeedfetcherutmcampaign/FeedanutmcontentGooglFeedfetcher/eedburnerutm_mediumfeedutmcampaign/FeedanutmcontentGooglFeedfetcherutmcampaign HEY
Does anyone know what's behind this or have any other insight into this?
Resolved: Problem is with UITextView data detectors.
Please go through 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 };
If you set UIDataDetectorTypeAll or UIDataDetectorTypeAddress or UIDataDetectorTypeCalendarEvent then iOS creates problems on iOS5.0 and Above.
textview.dataDetectorTypes=UIDataDetectorTypeAll;
Or
textview.dataDetectorTypes=UIDataDetectorTypeAddress | UIDataDetectorTypeCalendarEvent;
Then sometimes it creates problem on iOS5.0 and above.
So you need to set data detectors explicitly :
textview.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With