Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
hello guys,

I have a NSArray of webpages' URLs , what is the best way to download all the links? every 5 sec i need to download all the links which are inside the array.

NSUrl? any better way?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
There is a section of the NSString documentation:
Creating and Initializing a String from an URL

There are many options for you to choose from to get an NSString containing the contents of a webpage given its URL.

-Lee
 

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
There is a section of the NSString documentation:
Creating and Initializing a String from an URL

There are many options for you to choose from to get an NSString containing the contents of a webpage given its URL.

-Lee

thanks bro, but what i am going to do is to download webpage!

NSURLConnection is a good choice?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I provided you with what I think are the best methods for achieving your goal. Did you try them and they were insufficient for your purposes? If so, what did happen and what were you hoping for?

-Lee
 

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
I provided you with what I think are the best methods for achieving your goal. Did you try them and they were insufficient for your purposes? If so, what did happen and what were you hoping for?

-Lee

as what i have mentioned again, i am not trying to fetch the content of webpage! i am trying to download the webpage on local machine.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
So I gave you information on how to get the contents stored at a particular URL into a string. You want those contents stored in a file. What would the next step be?
http://developer.apple.com/library/...String/writeToFile:atomically:encoding:error:

If I was doing this particular task, I'd be writing a shell script that used wget or curl depending on availability, but if you're going "heavy-weight" and using Objective-C, I'd use the NSString methods above because they're what I know. There may well be a single method elsewhere that will do this in one step.

-Lee
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
is there anyone who can show me an example how to download a webpage into a folder using NSURLConnection?

Why use NSURLConnection and not NSURLDownload?

NSURLDownload provides an application the ability to download the contents of a URL directly to disk. It provides an interface similar to NSURLConnection, adding an additional method for specifying the destination of the file.

Isn't that what you want?


The NSURLDownload chapter of the URL Loading System Programming Guide that chown33 kindly pointered you towards has lots of examples of using NSURLDownload with lots of detailed explanation.
 

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
Why use NSURLConnection and not NSURLDownload?



Isn't that what you want?


The NSURLDownload chapter of the URL Loading System Programming Guide that chown33 kindly pointered you towards has lots of examples of using NSURLDownload with lots of detailed explanation.
because my application gonna be baseed on IOS! NSURLDownload does not work on IOS.
 
Last edited:

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
because my application gonna be baseed on IOS! NSURLDownload does not work on IOS.

1) you didn't say iOS, which meant everyone thought you were using OS X, because:
2) you're posting in the wrong forum. Go to the iOS programming forum for iOS-specific questions.

Acting exasperated that we don't know a detail of your question you didn't mention serves only to frustrate those that might help you here and on the iOS forum. Be specific with your questions, it will benefit everyone.

-Lee
 

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
1) you didn't say iOS, which meant everyone thought you were using OS X, because:
2) you're posting in the wrong forum. Go to the iOS programming forum for iOS-specific questions.

Acting exasperated that we don't know a detail of your question you didn't mention serves only to frustrate those that might help you here and on the iOS forum. Be specific with your questions, it will benefit everyone.

-Lee

i think you are facing that issue so much emotional ! NSURLConnection works on MAC OSX and IOS, so i does not matter i ask this question here or in iphone forum!

what i need to know is how to download a webpage using NSURLConnection, thats all :)
 

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
Did you try searching?
Google search terms: download a webpage using NSURLConnection

Did you try reading the class reference doc for NSURLConnection, and looking at the linked sample code.

Did you try anything other than asking someone to give you the answer?
What have you tried?

yes i searched, but there was no sample for that! were you able to find one?
yes i tried, for NSURLDownload there is a clear and helpful documentation that exactly helps you for this matter, but for NSURLConection its not that easy to find how it works!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.