Hi,
I have this code and the guard let storekitProduct is always returning nil, no matter what and is therefore quitting the function. How do I fix this? Thanks in advanced!
Code
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have this code:
static var viewModels = [RestaurantListViewModel]() {
didSet {
dataSet = true
print("data set")
}
}
When it didSet is called, I want it to change a state in another struct, how can I accomplish this?
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 have looked around and am confused about deep linking to a view that is not the default view, or passing information to that view which then impacts what is shown. Please help.
Note: I am using the UIKit lifecycle
I have a key pairs array:
["Id": XmGjU9gxS5s0CzP4S6-bHw, "Name": Pizzeria La Rocca, "Url": https://www.yelp.com/biz/pizzeria-la-rocca-seattle?adjust_creative=sxCnBn1t8D3B-4MLGRB_2g&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=sxCnBn1t8D3B-4MLGRB_2g, "Rating": 5, "Img": https://s3-media1.fl.yelpcdn.com/bphoto/kE6hbIfi4WdlIW52SF5KUw/o.jpg]
How do I convert this to my struct?
struct RestaurantListViewModel: Identifiable {
let name: String
let imageUrl: URL
let id: String
let rating: Double
let url: String
// let category: Array<String>
}
Thank you in advanced!
How do I create an action that occurs when a child view (showing through a NavigationLink) is dismissed? I am trying to pass a value, but can't create a function to use the received value.
Thanks in advanced.
Hi!
I have this code, and when I do it according to the documentation, it doesn't let me swipe. Please Help!
Code.txt
Hey,
Whenever I upload a build to App Store Connect, I get an Invalid Binary with the error:
One or more dynamic libraries that are referenced by your app are not present in the dylib search path
Here are all the frameworks in my project:
And here is my Cocoapods:
Thx in advanced!
Edit
Here is my output from running otool -L:
otool -L Output
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store Connect
Frameworks
Swift Packages
Hi,
I am helping Evan Richman with the team id L7JQRVXU2V transition to my business (MCRICH LLC), but the status has been in transition for about 1.5 weeks, even though I have gotten the confirmation code. What is going on?
Please help!
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, 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!
Hi,
how can I check if someone has allowed local notifications?
Thanks in advance!
Hi,
I keep getting the error "Type '()' cannot conform to 'View'; only struct/enum/class types can conform to protocols" on lines 99 and 100, here is the code:
import SwiftUI
import Intents
import UserNotifications
class Riddles {
static var text = String()
static var isWednesday = Bool()
static func largeWidget() {
Riddles.checkWeekday()
let userDefaults = UserDefaults(suiteName: "group.SetRiddle")
if Riddles.isWednesday == false {
if userDefaults?.value(forKey: "currentRiddle") != nil || userDefaults?.value(forKey: "previousRiddle") != nil {
Riddles.text = "\(UserDefaults(suiteName: "group.SetRiddle")?.value(forKey: "currentRiddle") as! String) \n\n\(UserDefaults(suiteName: "group.SetRiddle")?.value(forKey: "previousRiddle") as! String)"
}else{
Riddles.text = "Please open app to display riddle"
}
}else {
Riddles.text = "Please open app to display riddle"
}
}
static func mediumWidget() {
Riddles.checkWeekday()
let userDefaults = UserDefaults(suiteName: "group.SetRiddle")
if Riddles.isWednesday == true {
if userDefaults?.value(forKey: "currentRiddle") != nil {
Riddles.text = UserDefaults(suiteName: "group.SetRiddle")?.value(forKey: "currentRiddle") as! String
}else{
Riddles.text = "Please open app to display riddle"
}
}else {
Riddles.text = "Please open app to display riddle"
}
}
static func checkWeekday() {
let today = Date()
let calendar = Calendar(identifier: .gregorian)
let components = calendar.dateComponents([.weekday], from: today)
if components.weekday == 4 {
Riddles.isWednesday = true
}else {
Riddles.isWednesday = false
}
}
}
struct Provider: IntentTimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date(), text: "", configuration: ConfigurationIntent())
}
func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date(), text: "", configuration: configuration)
completion(entry)
}
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
var entries: [SimpleEntry] = []
// Generate a timeline consisting of five entries an hour apart, starting from the current date.
let currentDate = Date()
for hourOffset in 0 ..< 5 {
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
let entry = SimpleEntry(date: entryDate, text: "", configuration: configuration)
entries.append(entry)
}
let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)
}
}
struct SimpleEntry: TimelineEntry {
let date: Date
let text: String
let configuration: ConfigurationIntent
}
struct RiddleWidgetEntryView : View {
var entry: Provider.Entry
@Environment(\.widgetFamily) var family: WidgetFamily
@ViewBuilder
var body: some View {
switch family {
case .systemMedium: Riddles.mediumWidget()
case .systemLarge: Riddles.largeWidget()
}
ZStack {
Text(Riddles.text)
.foregroundColor(.black)
.font(Font.system(size: 20))
}
}
}
@main
struct RiddleWidget: Widget {
let kind: String = "RiddleWidget"
var body: some WidgetConfiguration {
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
RiddleWidgetEntryView(entry: entry)
}
.configurationDisplayName("My Widget")
.description("This is an example widget.")
.supportedFamilies([.systemMedium, .systemLarge])
}
}
struct RiddleWidget_Previews: PreviewProvider {
static var previews: some View {
RiddleWidgetEntryView(entry: SimpleEntry(date: Date(), text: "This Weeks Riddle: ", configuration: ConfigurationIntent()))
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}
Thanks in advance
Hi, I have this code in a designated file called IAP Manager to handle all things related to in-app purchases.
import StoreKit
import Foundation
final class IAPManager: NSObject, SKProductsRequestDelegate, SKPaymentTransactionObserver {
static let shared = IAPManager()
private var products = [SKProduct]()
private var productBeingPurchased: SKProduct?
enum Product: String, CaseIterable {
case removeAds = "JokesRUs.RemoveAds"
}
public func fetchProducts() {
let request = SKProductsRequest(productIdentifiers: Set(Product.allCases.compactMap(({ $0.rawValue }))))
request.delegate = self
request.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
products = response.products
}
func request(_ request: SKRequest, didFailWithError error: Error) {
guard request is SKProductsRequest else {
return
}
print("Product fetch request failed")
}
public func purchase(product: Product) {
guard SKPaymentQueue.canMakePayments() else {
return
}
guard let storeKitProduct = products.first(where: { $0.productIdentifier == product.rawValue }) else {
return
}
let paymentRequest = SKPayment(product: storeKitProduct)
SKPaymentQueue.default().add(self)
SKPaymentQueue.default().add(paymentRequest)
}
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
transactions.forEach({ transaction in
switch transaction.transactionState {
case .purchasing:
//No op
break
case .purchased:
handlePurchase(transaction.payment.productIdentifier)
break
case .failed:
break
case .restored:
break
case .deferred:
break
@unknown default:
break
}
})
}
private func handlePurchase(_ id: String) {
UserDefaults.standard.setValue(true, forKey: id)
print(id)
}
}
And then I have this code to call it:
IAPManager.shared.purchase(product: .removeAds)
The problem is I can't figure out how to get the price for the location from StoreKit.
Thanks in advance!
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store Connect
Swift
StoreKit
Xcode
Hi,
I am using Mac in Cloud, because I don't have a mac, and I am unable to load my app on to my phone, therefore I am trying to use testflight. The problem is my app is unpublished and the buttons for in-app aren't working. Any ideas.
Thanks in advance!
PS: The in-app purchase status is waiting for upload.
Topic:
App & System Services
SubTopic:
StoreKit
Tags:
In-App Purchase
iPhone
StoreKit Test
TestFlight