Post

Replies

Boosts

Views

Activity

Reply to Why is this crashing?
Ok, thanks. Here is my code designed to check if purchased/purchase and then equip the icon, and refresh. However, the part with the if runs before it can be purchased, if it is already purchased then it works fine. func setIcon(name: String) {             IconChange.setIconPurchased = false             print(name)             let app = UIApplication.shared             if #available(iOS 10.3, *) {                 if app.supportsAlternateIcons {                     checkForUnlocked(name: name)                     if IconChange.setIconPurchased == true {                         app.setAlternateIconName(name, completionHandler: { (error) in                             if error != nil {                                 print("error = \(String(describing: error?.localizedDescription))")                                 // Create new Alert                                 let dialogMessage = UIAlertController(title: "Failed to change icon", message: "There was an error changing the icon: \(error!)", preferredStyle: .alert)                                                                  // Create OK button with action handler                                 let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) - Void in                                     print("\"Failed to change icon\" alert was dismised")                                  })                                                                  //Add OK button to a dialog message                                 dialogMessage.addAction(ok)                                 // Present Alert                                 self.present(dialogMessage, animated: true, completion: nil)                             }else {                                 print("Changed Icon Sucessfully.")                                 self.iconSelected = name                                 UserDefaults.standard.setValue(name, forKey: "iconSelected")                                 IconChange.pushBack = true                                 self.navigationController?.popViewController(animated: true)                                 }                             })                         }                     }                 }             }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Wait until transaction is finished
If you were accustomed to completion handler pattern, it would not be so difficult. You will find sample code that explains how to properly use this. I was not able to find the answer in documentation and when I create a completion handler on skpaymentqueue, it gives me errors for it not conforming to protocols. IAP Manager SKPaymentQueue - https://developer.apple.com/forums/content/attachment/2431d31f-1b9e-4266-b670-32c2e434b194
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Why is this crashing?
Would you like me to give you my project so you can run it? The if I am talking about is on line 15 and it is supposed to prompt to get purchased if not purchased already, and then refresh and select it. However, the if on line 15 is running before you purchase it. Thank you for all the help you two!
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Why is this clearing?
Sorry my bad, I was going quickly and didn't clarify. This function is running and immediately after, the array that is appended with a joke is cleared and set to nil.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Why is this clearing?
Sorry my bad, I was going quickly and didn't clarify. This function is running and immediately after, the array that is appended with a joke is cleared and set to nil.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Unable to install XCode
You need at least 41 gb of storage
Replies
Boosts
Views
Activity
Jun ’21
Reply to Notifications and ViewControllers
Thank you so much. Will check out the tutorial.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
I got what I wanted to do by posting to the Notification center when I am done with it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Why is this crashing?
Ok, thanks. Here is my code designed to check if purchased/purchase and then equip the icon, and refresh. However, the part with the if runs before it can be purchased, if it is already purchased then it works fine. func setIcon(name: String) {             IconChange.setIconPurchased = false             print(name)             let app = UIApplication.shared             if #available(iOS 10.3, *) {                 if app.supportsAlternateIcons {                     checkForUnlocked(name: name)                     if IconChange.setIconPurchased == true {                         app.setAlternateIconName(name, completionHandler: { (error) in                             if error != nil {                                 print("error = \(String(describing: error?.localizedDescription))")                                 // Create new Alert                                 let dialogMessage = UIAlertController(title: "Failed to change icon", message: "There was an error changing the icon: \(error!)", preferredStyle: .alert)                                                                  // Create OK button with action handler                                 let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) - Void in                                     print("\"Failed to change icon\" alert was dismised")                                  })                                                                  //Add OK button to a dialog message                                 dialogMessage.addAction(ok)                                 // Present Alert                                 self.present(dialogMessage, animated: true, completion: nil)                             }else {                                 print("Changed Icon Sucessfully.")                                 self.iconSelected = name                                 UserDefaults.standard.setValue(name, forKey: "iconSelected")                                 IconChange.pushBack = true                                 self.navigationController?.popViewController(animated: true)                                 }                             })                         }                     }                 }             }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
If you were accustomed to completion handler pattern, it would not be so difficult. You will find sample code that explains how to properly use this. I was not able to find the answer in documentation and when I create a completion handler on skpaymentqueue, it gives me errors for it not conforming to protocols. IAP Manager SKPaymentQueue - https://developer.apple.com/forums/content/attachment/2431d31f-1b9e-4266-b670-32c2e434b194
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
IDK? That is what I am trying trying to figure out. Once I figure that out. It is much easier. IAP Manager.Swift - https://developer.apple.com/forums/content/attachment/1ab567f7-538a-4a78-a9c7-79ebf3f334a4
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
Somewhat, I followed some YouTube tutorials. I understand that the purchasing state is while it is being purchased, and I understand failed, purchased, and restored. I just don't know where this fits into it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
After the transaction has taken place. I want to trigger the transaction, and then run an if sentence after that. However, it runs before. Therefore, I need to figure out how to do call completion after the transaction.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
So then, how do I write completion in the correct place?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
The thing is, there is no error, it just calls completion() too early.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Why is this crashing?
Once an icon gets purchased, setIconPurchased gets set to true, and then if it equals true it does more actions.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Why is this crashing?
Would you like me to give you my project so you can run it? The if I am talking about is on line 15 and it is supposed to prompt to get purchased if not purchased already, and then refresh and select it. However, the if on line 15 is running before you purchase it. Thank you for all the help you two!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Why is this crashing?
Ok, but I am still wondering about how to get the things to trigger if setIconPurchased = true
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21