27

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?

Community
  • 1
  • 1
Jim
  • 1,014
  • 1
  • 11
  • 22
  • 1
    You should file a [bug report](http://bugreport.apple.com) with this info, along with a sample project that reproduces the issue. – Lily Ballard Jan 21 '11 at 23:00
  • OK, will do. But I'm still hoping for a workaround that will not involve scrapping NSDataDetector. – Jim Jan 21 '11 at 23:30
  • 2
    For anyone else running this: It's filed with Apple under problem ID 8917104. You can reference that in your bug report, should you make one. – Jim Jan 26 '11 at 03:49
  • Smells like a framework bug. – uchuugaka Dec 19 '13 at 00:29

2 Answers2

1

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;
Gaurav Borole
  • 796
  • 2
  • 13
  • 32
0

You could preprocess the text replacing those links that make trouble.

Lucas Zamboulis
  • 2,494
  • 5
  • 24
  • 27
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135