1.Build Phases -> Link Binary With Libraries 에서

CoreSpotlight.framework 추가하기.


2. 설명이미지



3. 코드 작성

#import <CoreSpotlight/CoreSpotlight.h>

#import <MobileCoreServices/MobileCoreServices.h>


-(void)addSportlightSearchItem:(NSString*)title desc:(NSString*)desc keywords:(NSArray*)keywords isHaveImageData:(BOOL)imageDataAvailable imageData:(NSData*)imageData {

    CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString*)kUTTypeImage];

    attributeSet.title = title;

    attributeSet.contentDescription = desc;

    attributeSet.keywords = keywords;

    if(imageDataAvailable) {

        attributeSet.thumbnailData = imageData;

    }else {

        attributeSet.thumbnailData = NULL;

    }


    CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier:desc domainIdentifier:desc attributeSet:attributeSet];

    [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError * __nullable error) {

        if(!error) {

            NSLog(@"등록완료");

        }

    }];

}




WRITTEN BY
블로blow
iOS 개발자 생활이야기

트랙백  0 , 댓글  0개가 달렸습니다.
secret