Alright no problem I will ask in a new thread. Thanks for all your help!
Post
Replies
Boosts
Views
Activity
@OOPer i have 4 different view controllers so I can attach the project if that's needed.
@OOper not sure if you have some experience with ARKit, but now I am trying to take the rating and display it on the user's camera. I know how to display simple text on the user's screen, but for some reason I'm getting an error when running this code:
override func viewDidLoad() {
				super.viewDidLoad()
				// Set the view's delegate
				sceneView.delegate = self
				configure()
				configureOCR()
				let text = SCNText(string: ocrTextView, extrusionDepth: 2)
				let material = SCNMaterial()
				material.diffuse.contents = UIColor.magenta
				text.materials = [material]
				let node = SCNNode()
				node.position = SCNVector3(x:0, y:0.02, z:-0.1)
				node.scale = SCNVector3(x:0.01, y:0.01, z:0.01)
				node.geometry = text
				sceneView.scene.rootNode.addChildNode(node)
				sceneView.autoenablesDefaultLighting = true
		}
When I run it, it crashes and gives an exception: Thread 1: Exception: "-[UITextInputTraits length]: unrecognized selector sent to instance 0x1035332b0"
Thanks so much, moving it worked.
Just to make sure I am understanding you: You are saying to move the DispatchQue.main.async method into the URLSession method?
@OOPer I got a part solution here:
URLSession.shared.dataTask(with: url) { data, response, error in
										guard let data = data else {
												print(error ?? "")
												return
										}
										html = String(data: data, encoding: .utf8)!
										let pattern = #"(\d.\d) out of 5 stars"										if let range = html.range(of: pattern, options: .regularExpression) {
												let rating = html[range].prefix(3)
												ocrText = ocrText + rating
												print("testing", ocrText) //prints with rating
										}
										
								}.resume()
								
								print("LATER:", ocrText) //doesn't print with rating
								
								
								
								
								
								DispatchQueue.main.async {
										self.ocrTextView.text = ocrText
										self.scanButton.isEnabled = true
								}
It is correctly getting the number of stars, but the problem is that I have a text view (as you can see in the above code) which I set equal to the string ocrText. However, I put two print statements: one inside the URLSession method and one outside the URLSessionMethod. I am trying to get the rating into the string ocrText, which works in the print statement in the URLSession method but not outside this method. How can I fix this?
BTW all the above code is in a seprate function and then I call this function in the viewDidLoad method.
edit: do you want the full code in the viewcontroller.swift ? its pretty long and i think there's a character limit for a post
@OOper As you would probably expect, the HTML is really long so I'll just include a snippet of the HTML which contains the rating:
</h2>
<div class="a-row a-size-small a-color-secondary"><span class="a-size-small" dir="auto">by </span><span class="a-size-small" dir="auto">John Bolton</span></div>
										</div>
										
												<div class="a-section a-spacing-none a-spacing-top-mini">
														<div class="a-row a-size-small">
<span aria-label="3.1 out of 5 stars">
		
<i class="a-icon a-icon-star-small a-star-small-3 aok-align-bottom"><span class="a-icon-alt">3.1 out of 5 stars</span></i>
</span>
Also html is a string.
@Claude I am searching for "stars"