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 05-12-2009, 03:32 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default Returning the "base" URL of a website

Hi all,

I want to try to return a web site's favicon file. I thought this should be relatively easy, but I guess not. I'm stuck trying to figure out how to return the "base" URL. What I mean is, for example, I don't want to return url=http://www.apple.com/iphone, I need to return =http://www.apple.com instead. I can't find an easy way to do this though, because there is no defined length, and all the different extensions (.com, .org, .net, .biz..., not to mention one for every country ) make it extremely difficult to parse out what I want from the URL.

How would I go about doing this?

Thanks for your help in advance!

Last edited by brian515; 05-12-2009 at 03:33 PM. Reason: The auto-correct inserted url tags automatically
brian515 is offline   Reply With Quote
Old 05-13-2009, 02:40 AM   #2 (permalink)
Beast Mode
 
Join Date: Dec 2008
Age: 21
Posts: 1,890
Default

you could split the url string by the "/" so it would split http://www.google.com/here

so use this code:

Code:
NSString *split2= @"http://www.google.com/here";
NSArray* split = [string2 componentsSeparatedByString:@"/"];
	NSString* webURL = [NSString stringWithFormat:@"%@",[split objectAtIndex:2]];
and that brings back www.google.com
__________________
I really do this.
Bertrand21 is offline   Reply With Quote
Old 05-13-2009, 09:25 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default

Quote:
Originally Posted by Bertrand21 View Post
you could split the url string by the "/" so it would split http://www.google.com/here

so use this code:

Code:
NSString *split2= @"http://www.google.com/here";
NSArray* split = [string2 componentsSeparatedByString:@"/"];
	NSString* webURL = [NSString stringWithFormat:@"%@",[split objectAtIndex:2]];
and that brings back Google
Awesome, thanks!

Another way I found to do it is that NSURL contains a path method. I can get the path, and subtract it from the full URL, and I am left with what I want.
brian515 is offline   Reply With Quote
Reply

Bookmarks

Tags
base, domain, favicon, url, website

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: 239
15 members and 224 guests
ADY, Alsahir, cacao, dacapo, Dani77, Desert Diva, djohnson, HemiMG, jansan, M@realobjects, MarkC, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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