How can I store a UIImage in an NSDictionary?

前端 未结 6 1180
无人及你
无人及你 2021-02-01 20:30

How can I store a UIImage in an NSDictionary?

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 20:39

    You cannot store UIImage object in a dictionary. You will have to convert the image into an NSData object and store that in dictionary.

    NSData *imgData = UIImageJPEGRepresentation(yourImage, 0.0f);
    [dictionary setObject:imgData forKey:@"your key"];
    

提交回复
热议问题