I am relatively new to swiftUI and curious to hear what would be a good approach to import a csv file into an app.
The file has around 3000 rows and 12 columns. The file will be updated with new information frequently (at least once or twice a week) so it is important that when a user launches the app the most updated data is always available.
Appreciate any ideas or resources I can check to learn more about this.
Thank you
Post
Replies
Boosts
Views
Activity
I have code that detects images via ARkit. When an image is detected, a swiftUI view is placed on top of the image. My code can detect the images, however I am only able to overlay one swiftUI view. I'd like the code to be responsive so that it can identify the image and place the appropriate view on top of it. Code below:
Code for SwiftUI imageOne.swift file
import SwiftUI
struct imageOne: View {
				var body: some View {
					 Text("hello imageOne")
		}
}
Code for SwiftUI imageTwo.swift file
import SwiftUI
struct imageTwo: View {
				var body: some View {	
					 Text("hello imageTwo")
		}
}
Code for ViewController.swift file
import UIKit
import SceneKit
import ARKit
import SwiftUI
class ViewController: UIViewController, ARSCNViewDelegate {
		@IBOutlet var sceneView: ARSCNView!
		
		override func viewDidLoad() {
				super.viewDidLoad()
				
				sceneView.delegate = self
				
		}
		
		override func viewWillAppear(_ animated: Bool) {
				super.viewWillAppear(animated)
				
				let configuration = ARImageTrackingConfiguration()
				guard let trackingImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) else {
				
						fatalError("Couldn't load tracking images")
						
						}
					
						configuration.trackingImages = trackingImages
						
				configuration.maximumNumberOfTrackedImages = 2
				
				sceneView.session.run(configuration)
		}
				
		
		override func viewWillDisappear(_ animated: Bool) {
				super.viewWillDisappear(animated)
				
	
				sceneView.session.pause()
		}
		
		func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
				
				guard let imageAnchor = anchor as? ARImageAnchor else {return nil}
				
				
				
				let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width,
												 height: imageAnchor.referenceImage.physicalSize.height)
				
				
				
				let planeNode = SCNNode(geometry: plane)
				
				planeNode.eulerAngles.x = -.pi / 2
				
				imageOneController(for: planeNode)
				
				let node = SCNNode()
				
				node.addChildNode(planeNode)
				
		
				return node
						
}
	
func imageOneController(for node: SCNNode) {
		
		
		let imageOneView = UIHostingController(rootView: imageOne())
		
		DispatchQueue.main.async {
				imageOneView.willMove(toParent: self)
				
				self.addChild(imageOneView)
				
				imageOneView.view.frame = CGRect(x: 0, y: 0, width: 500, height: 500)
				
				self.view.addSubview(imageOneView.view)
				
				self.showImageOne(hostingVC: imageOneView, on: node)
				
		}
		
		}
func imageTwoController(for node: SCNNode) {
		
		
		let imageTwoView = UIHostingController(rootView: imageTwo())
		
		DispatchQueue.main.async {
				imageTwoView.willMove(toParent: self)
				
				self.addChild(imageTwoView)
				
				imageTwoView.view.frame = CGRect(x: 0, y: 0, width: 500, height: 500)
				
				self.view.addSubview(imageTwoView.view)
				
				self.showImageTwo(hostingVC: imageTwoView, on: node)
				
		}
		
		}
		
func showImageOne(hostingVC: UIHostingController<imageOne>, on node: SCNNode) {
				
				let material = SCNMaterial()
				
				hostingVC.view.isOpaque = false
				material.diffuse.contents = hostingVC.view
				node.geometry?.materials = [material]
				
				hostingVC.view.backgroundColor = UIColor.clear
				
		}
	
func showImageTwo(hostingVC: UIHostingController<imageTwo>, on node: SCNNode) {
				
				let material = SCNMaterial()
				
				hostingVC.view.isOpaque = false
				material.diffuse.contents = hostingVC.view
				node.geometry?.materials = [material]
				
				hostingVC.view.backgroundColor = UIColor.clear
				
		}
		
}
				
The images on my AR Resource are also called imageOne and imageTwo, same each of the swiftUI views