|
Hi guys, I've been struggling whole day with the two tasks from day 26. challenge and you're my last hope. When it comes to task 1, which particularly is: "If users try to visit a URL that isn’t allowed, show an alert saying it’s blocked." What I did here was:
Unfortunately, what this thing does is it shows the alert every time I attempt to enter any other website than the one that initially loaded when the app launched (which, in my instance, is 'apple.com'), no matter what website I try to enter. Maybe the problem comes from the fact that I can't fully grasp what the "host" in the code is and whether it 'contains' a website? I'm just confused. Task no. 3: "For more of a challenge, try changing the initial view controller to a table view like in project 1, where users can choose their website from a list rather than just having the first in the array loaded up front." Oh boy, how much I screwed that one up. I'm totally lost with the relation between the detail view controller and the view controller, I tried to somehow connect them to make it work but I had to scrap everything, as the code started to turn into an array of a million errors. What's surprising though, it didn't pose that much of a problem in Day 23. Milestone. Here, however, it's one big clustertruck. If anyone was willing to share some time to explain what should be done here in a few steps with some important side notes where needed, I would be very grateful. Have a nice weekend y'all! |
|
Apparently being stubborn enough is all what it takes, cause I solved it :D Of course I'll be more than happy to help if anyone has a similar problem to mine! |
|
|
I am absolutely having this problem and I can't tell if it's the www. that's tacked on the beginning of "www.apple.com" when it comes back from the host but that can't be it... cause hacking with swift works both ways... |
|
hey @MateusZ I'm super curious how you fixed this? I'm getting the same thing and I can't find the fix for it... our code isn't EXACTLY alike (I don't have the else in my if statement around the decisionHandler but otherwise it's the same) |
|
Call this function right before
|
|
Hi guys i made this, and works. Hope i can help anyone in the same situation:
|
|
Hey @MateusZ did we need a detailVC for this one? I was simply trying to change the viewcontroller to a tableviewcontroller, and on table rowdidtap or whatever (sorry im in bed so from memory) compiling the url to open as opposed to doing one hard coded. Can it not be done this way? |
|
Well... it was rather challenging task to complete (the task 1 at least, the rest two were just fine) because of a small and persisting bug. Strange enough though, as I initially wrote the code by myself as many mentioned here by putting alert controller before decisionHandler(.cancel) but alert persisted dispite i choose a site from allowed list. The result that worked for me, and so far works as expected i.e. if I try to click on links that lead to other sites it denies to open and shows the propert alert, was posted by @abdullatif. You don't really need to write a function though, but simply put that line before decisionHandler(.cancel)
Hope it will be useful for someone who is struggling with that task... |
|
Hi all! I have been programming my app without a storyboard. I have a problem with 3 tasks. I created a new UITableViewController and from there passed all the data to the second controller. NavigationController, toolbarItems stopped working on my main controller.
|
|
Challenge 1 I was actually having an issue trying to figure out how to get an alert to pop up since all of the links on the HWS and Apple page seemed to work fine. Maybe this will help. I added Once on google perform a search for something and then try selecting a search result. For the alert, I created an alert function and then called it just before the decisionHandler. This seemed to work for me.
|
SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.