Hi,
I have this code that I need to run in the exact line order, but I can't figure out how to do it.
Things I have tried:
DispatchQueue Aysnc
completion handler functions
Code:
let pickedCat = Int.random(in: 1...4)
//print("picked cat: \(pickedCat)")
if pickedCat == 1 {
getRandomJokes()
randomJoke.text = "Random Joke: \(self.DadJokes)"
//print("Random Joke: \(self.DadJokes)")
}else if pickedCat == 2 {
getAssistantJokes()
randomJoke.text = "Random Joke: \(self.AssistantJokes)"
//print("Random Joke: \(self.AssistantJokes)")
}else if pickedCat == 3 {
getKnockKnockJokes()
randomJoke.text = "Random Joke: \(self.KnockKnockJokes)"
//print("Random Joke: \(self.KnockKnockJokes)")
}else if pickedCat == 4 {
getRandomJokes()
randomJoke.text = "Random Joke: \(self.RandomJokes)"
//print("Random Joke: \(self.RandomJokes)")
}
if randomJoke.text == "Random Joke: " {
randomJoke.text = "Random Joke: Failed to connect to server"
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Whenever I run this code, after I have purchased something and it shifts up after leaving and reopening the page it crashes with the error "Index out of range".
Code - https://developer.apple.com/forums/content/attachment/86665b01-4c50-47bd-a14d-ef95b58db511
Ideas? Thanks in advance!
Ps: I can provide full project if needed.
Hi,
How can I wait until an IAP transaction/restore is finished?
Thanks in advanced.
Hi,
I would like to be able to take two fields of a firestorm document and then set two UILabels to those fields. Here is my code:
import SafariServices
import WebKit
import Firebase
class TheRiddle: UIViewController {
@IBOutlet weak var leading_TheRiddle: NSLayoutConstraint!
@IBOutlet weak var trailing_TheRiddle: NSLayoutConstraint!
@IBOutlet weak var CurrentRiddle: UILabel!
@IBOutlet weak var PreviousRiddle: UILabel!
var menuOut = false
override func viewDidLoad() {
super.viewDidLoad()
let db = Firestore.firestore()
db.collection("TheRiddle").document("Riddles").getDocument { (document, error) in
//check for error
if error == nil {
//check if document exists
if document != nil {
}else {
if let currentRiddle = document!.get("CurrentRiddle") as? String {
self.CurrentRiddle.text = "This Weeks Riddle: " + currentRiddle
}
if let previousRiddle = document!.get("CurrentRiddle") as? String {
self.CurrentRiddle.text = "Previous Riddle: " + previousRiddle
}
}
}
}
}
@IBAction func RiddleAnswerForm(_ sender: Any) {
let vc = SFSafariViewController(url: URL(string: "https://forms.office.com/Pages/ResponsePage.aspx?id=ytAqTDte6UK-KD5v_kOm4Y843IzqmYtFlDtLrfRYsi1UMFpUMk1GN01GS05BVFlJUElONk4yR1hKUCQlQCN0PWcu")!)
present(vc, animated: true)
}
@IBAction func menuTappedTheRiddle(_ sender: Any) {
if menuOut == false {
leading_TheRiddle.constant = 150
trailing_TheRiddle.constant = -150
menuOut = true
}
else {
leading_TheRiddle.constant = 0
trailing_TheRiddle.constant = 0
menuOut = false
}
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: {
self.view.layoutIfNeeded()
}) { (animationComplete) in
print("The animation is complete")
}
}
}
Thanks in advance!
Hi,
I am making an app and I am using tab navigation controller and the navigation controller, and whenever I push into another view controller through a segue, if I go to a different tab, then back to that one it's still on the pushed to view controller. Ideas on how to fix this.
Thanks in advance!
Hi,
I have this error:
Provisioning profile "iOS Team Provisioning Profile: com.Mcrich23.Pickt" doesn't include the com.apple.runningboard.assertions.webkit entitlement
However, I can't add this entitlement because it pretty much does not exist. Any ideas?
Hi,
Something weird is going on with my code. I want it so when someone allows me to send notifications, if they go into my setting view controller to see that toggled on. Here is a link to my project: https://www.icloud.com/iclouddrive/0PDX_ZK3kyamqHjV8-hlDhZbw#Riddle_Wednesday
Thanks in advance!
Hi, this code is returning nil always. So frustrating!
let today = Date()
let calendar = Calendar(identifier: .gregorian)
let components = calendar.dateComponents([.weekday], from: today)
let nineThirtyToday = Calendar.current.date(
bySettingHour: 90,
minute: 30,
second: 0,
of: today)
print(nineThirtyToday as Any)
if components.weekday == 4 {
if today = nineThirtyToday! {
if UDM.shared.widgetDefaults?.value(forKey: "currentRiddle") as! String == currentRiddleFinal {
currentRiddleFinal = "Waiting for update from server"
}
}else {
print("Not Nine Thirty")
}
}
UDM.shared.widgetDefaults?.setValue(currentRiddleFinal, forKey: "currentRiddle")
print("Current Riddle: \(currentRiddleFinal)")
}
Thanks in advance!
Hi,
Is there a way I can use something like an res feed to update text weekly without using a paid server?
Thanks in advance!
Hi, I am trying to make it so that my notification opens up the “The Riddle” View controller, but I can’t figure out how. Here is a link: https://www.icloud.com/iclouddrive/0PDX_ZK3kyamqHjV8-hlDhZbw#Riddle_Wednesday
Thanks in advance!
I have this struct:
struct Final_Restaurant_View: View {
var data: [RestaurantListViewModel]
@State private var isHome = false
var body: some View {
NavigationView{
VStack {
List(data) {
data in
layout(data: data)
}
.listStyle(GroupedListStyle())
Button(action: {
isHome = true
}, label: {
Text("Go Home")
})
.padding()
}
.fullScreenCover(isPresented: $isHome, content: {
ContentView()
})
.navigationBarTitle("Results")
}
}
}
Which is supposed to get data and display it in a list. The problem is that I can't find anything about sections on a table structured like this and therefore, it goes wack with the section title. Any Ideas???
I am an aspiring developer and would like some help with this issue, that is super annoying.
Any Idea why I am getting this message?
Thread 1: "[<UIViewController 0x7ff3bdc08a80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key leadingHome."
I have tried:
Deleting home and re-adding it
reconnecting all the points on the home controller
Deleting the class and re-adding it
Making a new class and changing Home over to it
Setting the constraints and menu button itself to the class
You can download my project at: https://www.icloud.com/iclouddrive/0vC-WfbeKKjLa6V05ofqhyayw#Riddle_Wednesday
Thanks so much in advance!
Hi,
how can I check if someone has allowed local notifications?
Thanks in advance!
I have an M1 Mac and I am on Monterey beta 4. I have Xcode 12 and whenever I try to run my iOS app on my Mac natively, I get this error message.
Could not attach to pid : “4837”
Lost Connection
Full Log
Any Ideas?
Thanks in advanced
Hi,
I am trying to install a swift package and I keep getting this error.
Error
When I install it any other way, I get this error:
Error
Any ideas on how to fix it?