Post

Replies

Boosts

Views

Created

Unable to deploy CloudKit Dev Schema to production
This will be the initial production schema for this container. When I attempt to start deployment, the Confirm Deployment dialog appears and spins for a while. It then reports "There was a problem loading the environment's status." When I clear the error the Confirm Deployment dialog reports: "No Changes to Deploy" "The schema in the development environment is the same as production." (spoiler, they are not the same) Any suggestions?
0
0
630
May ’21
In SwiftUI I would like to declare an @ObservedObject var with a type defined in a protocol...
See sample code below... Basically it's a galleryView with a dataSource that can add/remove items dynamically. It works as expected when GalleryView's dataSource variable has a type (that conforms to ObservableObject) However when I change dataSource's type to be a protocol, I can't seem to get my code to compile. Any guidance on how to use a protocol in GalleryView, and continue to keep the UI updating when the model object's item list changes? thanks! Mike protocol GalleryDataSource: ObservableObject {     var itemCount: Int { get }     func item(for index: Int) - String } class GalleryModel: ObservableObject {     static let test1: GalleryModel = GalleryModel(items: ["A","B","C"])     @Published var items: [String]     init(items: [String]) {         self.items = items     } } extension GalleryModel: GalleryDataSource {     var itemCount: Int {         return items.count     }     func item(for index: Int) - String {         return items[index]     } } struct ContentView: View {     var model: GalleryModel = GalleryModel.test1     var body: some View {         VStack {             GalleryView(dataSource: model)             Button("Add Item") {                 model.items.append("\(model.items.count)")             }         }     } } struct GalleryView: View {     @ObservedObject var dataSource: GalleryModel //GalleryDataSource     var body: some View {         ScrollView(.horizontal, content: {             HStack {                 ForEach(0..self.dataSource.itemCount, id:\.self) { index in                     Text(dataSource.item(for: index))                         .padding()                 }             }         })     } }
1
0
4.7k
May ’21
Not sure how to add Prev/Next buttons in my SwiftUI List's Detail view.
I have a SwiftUI app with a List displaying an array of model objects. When the user taps a list item we see its detail view. I want to add previous and next buttons to my detail view, but I'm not sure what needs to happen when previous/next are tapped. (see code below for what I'm looking to do) My first thought is to make the model variable in the DetailView be a binding, but I'm not sure how this would tie in with the NavigationLink 'stuff' any/all suggestions appreciated. thanks! class Model: Identifiable {     var modelValue: Int     init(modelValue: Int) {         self.modelValue = modelValue     }     static let testData = [Model(modelValue: 3), Model(modelValue: 7), Model(modelValue: 31)] } class ModelManager {     static let shared = ModelManager()     let modelList = Model.testData     func previous(for model: Model) - Model? {         if let index = modelList.firstIndex(where: {$0.modelValue == model.modelValue}) {             if index 0 {                 return modelList[index - 1]             }         }         return nil     }     func next(for model: Model) - Model? {         if let index = modelList.firstIndex(where: {$0.modelValue == model.modelValue}) {             if index modelList.count - 1  {                 return modelList[index + 1]             }         }         return nil     } } struct ContentView: View {     let manager:ModelManager = ModelManager.shared     var body: some View {         NavigationView {             List(manager.modelList) { object in                 NavigationLink(                     destination: DetailView(model: object, previous: manager.previous(for: object), next: manager.next(for: object)),                     label: {                         Text("fred \(object.modelValue)")                     })             }         }     } } struct DetailView: View {     var model: Model     var previous: Model?     var next: Model?     var body: some View {         VStack {             HStack {                 if previous != nil {                     Button("Previous") {                         // goto previous                     }                 }                 Spacer()                 if next != nil {                     Button("Next") {                         // goto next                     }                 }             }             Text("value: \(model.modelValue)")             Spacer()         }     } }
1
0
1.6k
Mar ’21
Looking to tweak default behaviour for a SwiftUI NavigationView in a TabView on iPad (in Portrait orientation)
At the top level, my app has a tab bar. the second tab's root view is a list view. When a user taps an item in the list, the app presents a detail view for the list item. The problem I'm currently having is the behaviour the first time the user taps the second tab's button in the tab bar (when running on an iPad in portrait. There is a navBar at the top, but the screen is otherwise empty. (tapping the left button on the navBar shows the list view, which allows the user to select an item which populates the main detail view) Is there some way (in swfitUI) to force the list view to show when in portrait? Alternatively/additionally, is there someway to present some instructional view in the otherwise empty view. (It doesn't appear to be creating a standard detail view here until the user exposes the list and picks an item) Here is some sample code that demonstrates what I'm describing. thanks in advance for any assistance! Mike import SwiftUI struct ContentView: View {     var body: some View {         TabView(){             FirstTabView()                 .tabItem {                     Text("First")                 }                 .tag(0)             SecondTabView()                 .tabItem {                     Text("Second")                 }                 .tag(1)         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()         .previewDevice(PreviewDevice(rawValue: "iPad8,1"))     } } struct FirstTabView: View {     var body: some View {         Text("First View")     } } struct SecondTabView: View {     var body: some View {         NavigationView {             NavigationLink(destination: Text("Detail View")) {                 Text("SummaryView")             }             .navigationBarTitle("Navigation")         }     } }
2
0
936
Sep ’20
An error occurred while trying to call the requested method validateMetadata. (1272)
I'm getting this error when attempting to upload an iOS app to iTunes Connect. I've tried using Transporter, and get the same result.I've also tried uploading a new version of an app that uploaded correctly in November and got the same result.Does anyone have any suggestions for possible causes for this error?thanks,
6
0
5.5k
Feb ’20