서버가 반환하는 그림 형식을 GIF로 판단하는 방법

/* :  */

    //pathExtension:  , lowercaseString:  
    NSString *extensionName = model.image_url.pathExtension;

    // gif 
    self.gifView.hidden = ![extensionName.lowercaseString isEqualToString:@"gif"];

/* :  ,  ,  */

+ (NSString *)qm_contentTypeForImageData:(NSData *)data {
    uint8_t c;
    [data getBytes:&c length:1];
    switch (c) {
        case 0xFF:
            return @"image/jpeg";
        case 0x89:
            return @"image/png";
        case 0x47:
            return @"image/gif";
        case 0x49:
        case 0x4D:
            return @"image/tiff";
        case 0x52:
            // R as RIFF for WEBP
            if ([data length] < 12) {
                return nil;
            }

            NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding];
            if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) {
                return @"image/webp";
            }

            return nil;
    }
    return nil;
}

좋은 웹페이지 즐겨찾기