Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-04-2010, 06:25 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 20
Default Need help grabbing the URL of a clicked link inside a UIWebView

Hi All,

Sorry to bother with this, but I have searched all over and I have tried everything I can think of (which admittedly may not be that great an endorsement) and I cannot find an answer.

Basically, I have a UIWebView and what I'm trying to do is detect if the link being clicked inside the active web page (in my webview) is an image. So, to that end I have implemented the following method:

Code:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
	
	//CAPTURE USER LINK-CLICK.
	if (navigationType == UIWebViewNavigationTypeLinkClicked) {
		NSURL *URL = [request URL];	
		NSLog(@"url is: %s ", URL);
	}	
	return YES;   
}
WHat I get from the above code is: @fiA (base64?)

I've tried all manner of different encoding methods, but nothing gives me any different response than that.

All I need to get is the url so that I can do a substring search and see if it contains .jpg, .gif, .png, etc and handle it properly if it contains one of those.

Any help would be MUCH appreciated...
darylbowden is offline   Reply With Quote
Old 01-04-2010, 06:42 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

The format specifier %s is only for C strings. If you want to see the description of an object, use %@ instead.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 01-04-2010, 06:55 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 20
Default

Awesome! God I'm slow...

So, one more thing. I'm sure this exists, but I haven't found it yet. Is there an instance method in NSString that will allow me to convert that NSURL into a readable string that I can compare against?
darylbowden is offline   Reply With Quote
Old 01-04-2010, 07:28 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Yes, every object has a "description" method that returns a string; by default it just gives the address, but most classes override it to give you a notion of the contents as well.

In short, you could compare [URL description] to whatever string you want.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 01-04-2010, 07:36 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 20
Default

Thanks so much Smasher, this is exactly what I was missing!
darylbowden is offline   Reply With Quote
Reply

Bookmarks

Tags
event handling, link, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 251
19 members and 232 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, DarkAn, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, MACralik, NSeven, prchn4christ, Rudy
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:52 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0