简体   繁体   中英

How can I save a website in Cocoa Touch and store it in an array?

I am just building an app for my first time. I've created it so that I open it and it opens web view and I have a button called "Save" (so it's just a web view inside the app with a little button below it). I would like to be able to save a website when I visit it. It doesn't need to label the save or anything, I just want it to save and I can click another button called "sites" and it will display my list of saved websites.

You will have to decide on some kind of storage method. A simple one would be create an NSMutableArray of the sites. Depending on the needs of the application, you could change this to something different. Then, saving the site is as simple as inserting an object that represents the page (maybe an NSURL or an NSString with the URL). The question Get current URL of UIWebView discusses several ways of getting a URL from a webview. You can then decide on a way to display the list of saved sites. Once a site is selected, you just have to pass it back to the webview.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM