MacOS内置的字典服务

xiaoxiao2021-02-28  7

原来MacOS内置了字典,可以通过API访问,这样验证一个单词是不是有效的英文单词就很简单了:

NSString *word = @"great"; CFRange r = DCSGetTermRangeInString(NULL, (__bridge CFStringRef)word, 0); if(r.location!=kCFNotFound) NSLog(@"valid word"); else NSLog(@"Invalid word"); API参考文档:

https://developer.apple.com/documentation/coreservices/1450556-dcsgettermrangeinstring?language=objc

转载请注明原文地址: https://www.6miu.com/read-2150045.html

最新回复(0)