Posts

Post marked as solved
1 Replies
194 Views
I've tried to create a simple CoreData entity and use the PreviewProvider to display the results. This worked fine (The first entity that got displayed was the GoalInformation). After this i've extended my entity with a relationship to another entity. This is a screenshot from the Xcode editor: More information about the entities: This is my ContentView struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Goal.information!.name, ascending: true)], animation: .default) private var items: FetchedResults<Goal> var body: some View { VStack { Text("count: \(items.count)") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } The preview of the PersistenceController looks like this: static var preview: PersistenceController = { let result = PersistenceController(inMemory: true) let viewContext = result.container.viewContext for _ in 0..<5 { let newItem = GoalInformation(context: viewContext) newItem.name = "Name" let newItem2 = Goal(context: viewContext) newItem2.information = newItem } do { try viewContext.save() } catch { let nsError = error as NSError debugPrint("\(nsError.code) + \(nsError.debugDescription)") } return result }() The init of the same struct is this: init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: "goalz_two") if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null") } container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { debugPrint("\(error.code) + \(error.description)") } }) } When i want to display it by clicking "Resume" this is the error I receive. Some more infos: Error Domain=FBProcessExit Code=4 "The process crashed." UserInfo={NSLocalizedFailureReason=The process crashed., BSErrorCodeDescription=crash, NSUnderlyingError=0x600002e0fc00 {Error Domain=signal Code=4 "SIGILL(4)" UserInfo={NSLocalizedFailureReason=SIGILL(4)}}} ---------------------------------------- MessageSendFailure: Message send failure for relaunch ================================== | RemoteHumanReadableError: The operation couldn’t be completed. Transaction failed. Process failed to launch. (process launch failed) | | BSTransactionError (1): | ==error-reason: process launch failed | ==transaction: <FBApplicationProcessLaunchTransaction: 0x600001931340> | ==NSLocalizedFailureReason: Transaction failed. Process failed to launch. (process launch failed) | ==precipitating-error: Error Domain=FBProcessExit Code=4 "The process crashed." UserInfo={NSLocalizedFailureReason=The process crashed., BSErrorCodeDescription=crash, NSUnderlyingError=0x600002e0fc00 {Error Domain=signal Code=4 "SIGILL(4)" UserInfo={NSLocalizedFailureReason=SIGILL(4)}}} | ==error-description: Process failed to launch. I'm so confused, because it worked when there was no relationship and i've only created one entity. Hope someone can help me out... Using Xcode Version 13.2.1 on macOS 12.3
Posted
by roblv.
Last updated
.
Post not yet marked as solved
0 Replies
320 Views
What I want to achive: I want to render a SKView with an SKScene that fills out all of my screen (Fullscreen). I have limited myself to one resolution for now. (iPad Air 4 with a resolution of 2360x1640) But if someone knows a solution that can be dynamically applied to all iDevices that would be even better. What I have: This is my GameViewController.swift file. I've tried all different scaleMode but no one works fine for my purpose. In the Level_0-1.sks file i've specified a custom Size with W:2360 and H:1640. class GameViewController: UIViewController { &#9;&#9;override func viewDidLoad() { &#9;&#9;&#9;&#9;super.viewDidLoad() &#9;&#9;&#9;&#9;if let view = self.view as! SKView? { &#9;&#9;&#9;&#9;&#9;&#9;let scene = SKScene(fileNamed: "Level_0-1") &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;view.presentScene(scene) &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;view.ignoresSiblingOrder = true &#9;&#9;&#9;&#9;&#9;&#9;view.showsFPS = true &#9;&#9;&#9;&#9;&#9;&#9;view.showsNodeCount = true &#9;&#9;&#9;&#9;&#9;&#9;view.showsPhysics = true &#9;&#9;&#9;&#9;} &#9;&#9;} } What happens: The problem is that the SKScene renders with black bars on the right and left side and on the top and bottom, even though I have specified the pixel resolution (as stated above) Hope someone can help!
Posted
by roblv.
Last updated
.
Post not yet marked as solved
0 Replies
637 Views
Hey Guys, i want to create a MapView in SwiftUI that gets a list of markers and displays them. But I also want the user to be able to click/tap on them. If they get tapped they should flip a bool to mark them as done. I've created a mockup array for my markers: struct Marker: Identifiable { &#9;&#9;let id = UUID() &#9;&#9;var coordinate : CLLocationCoordinate2D &#9;&#9;var done : Bool } let markers = [ &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.882975, longitude: 10.558585), done: true), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.883329, longitude: 10.559225), done: true), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.883296, longitude: 10.558216), done: false), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.882614, longitude: 10.559574), done: true), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.882425, longitude: 10.559263), done: false), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.882607, longitude: 10.557679), done: false), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.883246, longitude: 10.557652), done: false), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.883753, longitude: 10.557711), done: false), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.884018, longitude: 10.558710), done: false), &#9;&#9;Marker(coordinate: CLLocationCoordinate2D(latitude: 51.881783, longitude: 10.559713), done: false), ] The problem is that nothing is happening when I tap on the markers. I've tried to print, toggle a bool, navigate etc. in .onTapGesture { } Here is the code for my Map: Map(coordinateRegion: $region, annotationItems: markers) { marker in &#9;&#9;&#9; MapAnnotation(coordinate: marker.coordinate) { &#9;&#9;&#9;&#9;&#9; Circle() &#9;&#9;&#9;&#9;&#9;&#9;&#9; .onTapGesture { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; // do something &#9;&#9;&#9;&#9;&#9;&#9;&#9; } &#9;&#9;&#9; } } $region is this: @State private var region = MKCoordinateRegion( &#9;&#9;&#9;&#9;center: CLLocationCoordinate2D(latitude: 51.882879, longitude: 10.558918), &#9;&#9;&#9;&#9;span: MKCoordinateSpan( &#9;&#9;&#9;&#9;&#9;&#9;latitudeDelta: 0.01, &#9;&#9;&#9;&#9;&#9;&#9;longitudeDelta: 0.01 &#9;&#9;&#9;&#9;) &#9;&#9;) Hope someone can help!
Posted
by roblv.
Last updated
.