2011-01-21 3 views
27

NSDataDetectorと​​を使用して、文字列内のリンク(たとえばhttps://stackoverflow.com/questions)を検索しています。一般的に、それが正常に動作しますが、文字列はスペースと別の単語に続いて、特定の非常に長いリンク(200 +文字)が含まれている場合、私はこの主張を取得:DDTokenCacheでこのアサーションを回避する方法とその意味は何ですか?

> 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 

これの背後にあることを知っている人もいるでしょうか、他の洞察がありますか?

+1

あなたはそのサンプルプロジェクトと一緒に、この情報を[バグレポート](http://bugreport.apple.com)を提出すべきです問題を再現します。 –

+0

OK、行います。しかし、私はまだNSDataDetectorを廃止しないで回避策を期待しています。 – Jim

+2

これを実行している他の人のために:それはAppleに問題ID 8917104で提出されています。 – Jim

答えて

0

問題を引き起こすリンクを置き換えるテキストを前処理することができます。

+0

#または?を挿入しようとする可能性があります。 _space_HEY –

+0

downvoterの前にリンクの後ろに - 説明してください。これは有効な回避策のように思えます:) –

1

解決済み:問題はUITextViewデータ検出器にあります。

UIDataDetectorTypesを通過してください:あなたはUIDataDetectorTypeAllまたはUIDataDetectorTypeAddressまたはUIDataDetectorTypeCalendarEventを設定した場合

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

は、iOSはiOS5.0以上の問題を作成します。

textview.dataDetectorTypes=UIDataDetectorTypeAll; 

それとも

textview.dataDetectorTypes=UIDataDetectorTypeAddress | UIDataDetectorTypeCalendarEvent; 

そして、時にはそれはiOS5.0にし、上記の問題を作成します。

ですから、明示的にデータ検出器を設定する必要があります。

textview.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber; 
関連する問題