How can I store a UIImage in an NSDictionary?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- back button text does not change
相关文章
- 现在使用swift开发ios应用好还是swift?
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
[dictionary setObject:yourImage forKey:@"whatever key you want"];
Untested ;-)
[dict setObject:image forKey:@"ImageToStore"];
OK I had this problem recently and the above solutions never worked for me. So if someone else finds their way here to solve the same problem, here is how it's done
// the 0.1 represents the compression quality 0.0 being lowest to 1.0 being the highest quality
then to get image back from dictionary use
Yes you can:
You cannot store UIImage object in a dictionary. You will have to convert the image into an NSData object and store that in dictionary.
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.