Search code examples
iosobjective-cswiftuiimagemwphotobrowser

How to get an UIImage out of an MWPhoto object?


I'm using an open source photo browser and it uses MWPhoto objects to display images instead of just UIImage. Everything works fine, except when I try to get the UIImage back out of an MWPhoto. It seems like there should just be a .image or .getImage method that would return the original UIImage... but there doesn't seem to be. Am I missing something? Or will I have to modify the library with an additional getter?

I mainly need this because I need to be able to compare two MWPhoto objects... but there is not a useful way to do this, so I figure comparing the UIImage of MWPhoto objects is the second best thing.


Solution

  • Actually image property is private so you have to make it accessible by removing the image property declaration from MWPhoto.m and write into MWPhoto.h.

    In MWPhoto.h

    ....
        @property (nonatomic) BOOL isVideo;
        @property (nonatomic, strong) UIImage *image;
    ....
    

    Now you can access like photo.image //photo is a instance of MWPhoto