[ios] sqlite3 full text search

Setting

Podfile
pod 'sqlite3'
Add LLVM prepprocessor macros at Project “Pod”‘s Target sqlite3
  • Debug : SQLITE_DEBUG, SQLITE_ENABLE_FTS3_PARENTHESIS, SQLITE_ENABLE_FTS3
  • Release : SQLITE_ENABLE_FTS3_PARENTHESIS, SQLITE_ENABLE_FTS3

스크린샷 2015-10-08 오후 6.42.52

Pods (build automation)
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "sqlite3"
      target.build_configurations.each do |config|
        if config.name == 'Debug'
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'COCOAPODS=1', 'SQLITE_DEBUG', 'SQLITE_ENABLE_FTS3_PARENTHESIS', 'SQLITE_ENABLE_FTS3'] 
        end
        if config.name == 'Release'	
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'COCOAPODS=1', 'SQLITE_ENABLE_FTS3_PARENTHESIS', 'SQLITE_ENABLE_FTS3'] 
        end
      end
    end
  end
end
Reference
광고

[ios] 텍스트 검색 (Latin Lingual)

영어 발음으로 검색을 지원할 때

다음 코드는 text -> 영어(latin)으로 치환해준다.

NSMutableString *mutableQuery = [[NSMutableString alloc] initWithString:query];
CFStringTransform((CFMutableStringRef)mutableQuery, NULL, kCFStringTransformToLatin, false);
CFStringTransform((CFMutableStringRef)mutableQuery, NULL, kCFStringTransformStripCombiningMarks, false);

치환된 코드를 가지고 DB에서 like검색을 하거나
메모리에 일부를 올려 일치 여부 또는 포함 여부를 필터 하면 된다.

중국어나 일본어나 한국어를 영어발음으로 검색하고 싶을 때(키보드 두드리기 어려울 때) 유용하다.

출처 Git  : Telegram iOS

=========================

If you want to offer text search in ios lingual below source code may need.

NSMutableString *mutableQuery = [[NSMutableString alloc] initWithString:query];
CFStringTransform((CFMutableStringRef)mutableQuery, NULL, kCFStringTransformToLatin, false);
CFStringTransform((CFMutableStringRef)mutableQuery, NULL, kCFStringTransformStripCombiningMarks, false);

Transform text (Korean, Japanese, Chinese…etc) to latin lingual format.

And then do it your way.

source : Git  : Telegram iOS

[ios] App crash when you try to render some special text.

Cause

CoreText render issue. Font unable to render special character.

Example

* reference : http://arstechnica.com/security/2015/05/beware-of-the-text-message-that-crashes-iphones/

 

لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ


 

 

Error Log


2015-03-31 17:24:29.893 YourAppName[3456:1360936]
CoreText: *** Unmapped "\U00010B3B" {name = AppleSDGothicNeo-Regular, size = 17.000000, matrix = 0x0, descriptor = {attributes = {type = mutable dict, count = 1,
entries =>
1 : {contents = "NSFontNameAttribute"} = {contents = "AppleSDGothicNeo-Regular"}
}
>}}
2015-03-31 17:24:29.894 YourAppName[3456:1360936]
CoreText: *** Unmapped "\U00010B3B" {name = AppleSDGothicNeo-Regular, size = 17.000000, matrix = 0x0, descriptor = {attributes = {type = mutable dict, count = 1,
entries =>
1 : {contents = "NSFontNameAttribute"} = {contents = "AppleSDGothicNeo-Regular

Similar Sympthoms

http://www.maclife.com/article/news/apple_coretext_rendering_bug_causes_crashes_ios_6_os_x_108

The way to avoid this problem

replace un-renderable text to white box character.