How can I store a UIImage in an NSDictionary?

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

How can I store a UIImage in an NSDictionary?

6条回答
  •  不要未来只要你来
    2021-02-01 20:44

    It depends on what you want to do with your NSDictionary. While, yes, you can store a UIImage in NSDictionary, you may not be able to use said dictionary object in instances where you need it to conform to certain standards.

    For example, you can use an NSDictionary as a value in standardUserDefaults, but only if every object in that dictionary is a property list object. UIImage is not a property list object. NSData is, so you can convert your UIImage to NSData with UIImageJPEGREpresentation, and store it that way, as mentioned above.

提交回复
热议问题