iosfreak iosfreak - 1 year ago 110
Objective-C Question

Get image URL from MWPhoto?

I am using the MWPhotoBrowser (here) and I am trying to get the image that you are currently on.

I try this:

MWPhoto *theObject = [photos objectAtIndex:currentPageIndex];
NSString *test = [theObject image];
NSLog(@"maybe? %@", test);

And I get this

maybe? <UIImage: 0x4e5e890>

That's good an all, but I want to get the URL of the current image.

Any help is appreciated,

Answer Source

in MWPhoto.h add:

- (NSURL *)url;
- (NSString *)path;

at line 45

in MWPhoto.m add:

// Return URL
- (NSURL *)url { return self.photoURL; }

// Return Path
- (NSString *)path { return self.photoPath; }

at line 88

Where your code is, do something like

MWPhoto *theObject = [photos objectAtIndex:currentPageIndex];
NSString *path = [theObject path];
NSURL *url = [theObject url];
NSString *urlString = [url absoluteString];
NSLog(@"path %@", path);
NSLog(@"url %@", path);

To make use of the NSURL, check out

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download