Posts

Post not yet marked as solved
0 Replies
374 Views
Hi, if I use mapkit how can I show the longitude and latitude of the center of the map? I don't mean the current location. I just need the coordinates of the shown position.
Posted Last updated
.
Post not yet marked as solved
0 Replies
390 Views
In this link (Apple Developer Document) use this to update a widget: - https://developer.apple.com/documentation/widgetkit/timelineprovider // Request a timeline refresh after 2.5 hours. let date = Calendar.current.date(byAdding: .minute, value: 150, to: Date()) let timeline = Timeline(entries: entries, policy: .after(date)) completion(timeline) This is my Code right now: struct Provider: IntentTimelineProvider {     let networkManager = NetworkManager()     func placeholder(in context: Context) -> SimpleEntry {         SimpleEntry(date: Date(), configuration: ConfigurationIntent(), clubnamehome: networkManager.clubNameHome)     } func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {         let entry = SimpleEntry(date: Date(), configuration: configuration, clubnamehome: networkManager.clubNameHome)         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, configuration: configuration, clubnamehome: networkManager.clubNameHome)             entries.append(entry)         } //wie oft geupdatet werden soll         let date = Calendar.current.date(byAdding: .minute, value: 15, to: Date())         let timeline = Timeline(entries: entries, policy: .after(date!)) completion(timeline) } } What am I doing wrong? Can someone please help me to integrate a refresh policy?
Posted Last updated
.
Post not yet marked as solved
0 Replies
465 Views
Hi, my widget does a json request at the beginning. But it doesn't stop. It makes 10-20 requests per second. How can I stop that? This is the timeline of my code: struct Provider: IntentTimelineProvider {     let networkManager = NetworkManager()     func placeholder(in context: Context) -> SimpleEntry {         SimpleEntry(date: Date(), configuration: ConfigurationIntent(), clubname: networkManager.clubName)     } func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {         let entry = SimpleEntry(date: Date(), configuration: configuration, clubname: networkManager.clubName)         completion(entry)     }     func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {         var entries: [SimpleEntry] = []       &#9;let currentDate = Date()         for hourOffset in 0 ..< 5 {             let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!             let entry = SimpleEntry(date: entryDate, configuration: configuration, clubname: networkManager.clubName)             entries.append(entry)         }     let nextUpdate = Calendar.current.date(byAdding: .hour, value: 1, to: Date())   let timeline = Timeline(entries: entries, policy: .after(nextUpdate))         completion(timeline)     } } This is my JSON Request: class NetworkManager: ObservableObject {     @Published var posts = [Post]()     @Published var clubName = "..."     @Published var teamId = "30"     @Published var gastMannschaft = "..."     let testStr = UserDefaults(suiteName: "....")!.string(forKey: "test")     func fetchData() {         let teamId = testStr ?? "47"         if let url = URL(string: "...=" + teamId) {.             let session = URLSession(configuration: .default)             let task = session.dataTask(with: url) { (gettingInfo, response, error) in                 if error == nil {                     let decoder = JSONDecoder()                     if let safeData = gettingInfo {                         do {                             let results = try decoder.decode(Results.self, from: safeData)                             DispatchQueue.main.async {                                  self.clubName = results.data[0].away_name                                  if #available(iOS 14.0, *) {                                     WidgetCenter.shared.reloadAllTimelines()                                 } else {                                     // Fallback on earlier versions                                 }   }                         } catch { print(error) }                     }                 }             }             task.resume()         }     } }
Posted Last updated
.
Post not yet marked as solved
3 Replies
6.1k Views
I have an app coded with UIKit and want to add a simple Widget with Widgetkit. How can I pass the data to the Widget? As you know the widget works with SwiftUI. I only need to pass one variable. Thats it. The rest will be done with SwiftUI. I tried it with UserDefaults but it didn't work.
Posted Last updated
.
Post not yet marked as solved
1 Replies
486 Views
Hello, i finished my first app with UIkit and want to add a widget to it because of ios 14. I know that widgets only work with SwiftUI. So my question is how can I pass a variable from UIkit to SwiftUI so that it can be displayed?
Posted Last updated
.
Post not yet marked as solved
0 Replies
344 Views
Hello, I have two Storyboards. One is called Main the other ist called intro. When the user starts the app I want an if else statement and ask for a variable. I want somethings like: If variable is ok then show Main Storyboard else show Intro Storyboard. How can I do that? Does anyone has a code snippet easy to understand? Thank You. I read somethings about appdelegate?
Posted Last updated
.
Post not yet marked as solved
0 Replies
455 Views
Hello, i want to write an app which asks the user with the first start of the app to choose between a few options. Depending what have been chosen the app will load some data from an api. The question will never appear again. Maybe I will give the user the option to change it in the settings. As a beginner in swift I thought I could use viewdidload. But that would show the question view on every start. But thats not what I want. What do I have to google for? Can you name me the thing I search? Or do I kinda have to set a variable which is for example 0 and if the user selects an option it will get something different then 0 and that will disable the asking view with an if function?
Posted Last updated
.
Post marked as solved
2 Replies
709 Views
Hello, i am creating an app with widget an want it to be available to use on the day of release of iOS 14. How can i manage that? When do i have to send it to apple. Or do the even accept iOS 14 apps before release?
Posted Last updated
.