Posts

Post marked as solved
5 Replies
1k Views
Hello! I just found that WWDC 21 date was dropped, ive been anticipating this date because I was excited to show off an app I've been developing for the past year. My question is instead of playgrounds, can it be an IPA file?. Also, where do we upload the questions that they asked on the website? Thanks! James
Posted Last updated
.
Post not yet marked as solved
1 Replies
629 Views
Hello! I am trying to figure out how to detect a collision, but no matter what I do, it seems to not want to work(Using didBegin). I have used multiple resources to no avail and im so close to banging my head against the wall lol. Im hoping someone can Identify what im doing wrong with it. I'll attach my class for you :) Thank you for any help! // //  GameView.swift //  DogeBall // //  Created by James Biser on 2/21/21. // import UIKit import SpriteKit import SceneKit import QuartzCore import CoreMotion class GameView: UIViewController, SKSceneDelegate, SKPhysicsContactDelegate {          @IBOutlet var gameView: UIView!     @IBOutlet weak var pointsLabel: UILabel!     @IBOutlet weak var livesLeftLabel: UILabel!               let player = SKSpriteNode(imageNamed: "gameElement.png")     let goal = SKSpriteNode(imageNamed: "goal.png")     var motionManager = CMMotionManager()     var destX:CGFloat  = 0.0     var destY : CGFloat = 0.0     @IBOutlet weak var SKGameView: SKView!          var scene = SKScene()     var toggle = true               override func viewDidLoad() {         // self.navigationController?.isNavigationBarHidden = true         scene.size =  gameView.bounds.size         scene.scaleMode = .aspectFill          SKGameView.presentScene(scene)          SKGameView.showsFPS = true          SKGameView.showsNodeCount = true          SKGameView.showsPhysics = true                                        player.position = CGPoint(x: SKGameView.frame.size.width/2, y: SKGameView.frame.size.height/2)          player.physicsBody = SKPhysicsBody(circleOfRadius: player.size.width / 2.0)          player.physicsBody?.affectedByGravity = false          player.physicsBody!.contactTestBitMask = 0          player.physicsBody?.collisionBitMask = 0                  //  goal.position = spawnGoalAtRandom()          goal.physicsBody = SKPhysicsBody(circleOfRadius: goal.size.width / 2.0)         goal.position = CGPoint(x: SKGameView.frame.size.width/2+9, y: SKGameView.frame.size.height/2+9)          goal.physicsBody?.affectedByGravity = false          goal.physicsBody!.contactTestBitMask = 0          goal.physicsBody!.collisionBitMask = 0          goal.physicsBody?.usesPreciseCollisionDetection = true          player.physicsBody?.usesPreciseCollisionDetection = true                   scene.addChild(goal)         scene.addChild(player)          motionManager.startAccelerometerUpdates()                  startAccelerometers()     }     func didBeginContact(contact : SKPhysicsContact){         print("cool")     }          func update(_ currentTime: TimeInterval, for scene: SKScene) {         print("update frame")     }     func spawnGoalAtRandom() - CGPoint{         let height = self.scene.frame.height         let width = self.scene.frame.width         let randomPosition = CGPoint(x: CGFloat(arc4random()).truncatingRemainder(dividingBy: height) - 10 , y: CGFloat(arc4random()).truncatingRemainder(dividingBy: width) - 10)                return randomPosition     }          var isTouched = false          override func touchesBegan(_ touches: SetUITouch, with event: UIEvent?) {         if let touch = touches.first {             if player.contains(touch.location(in: scene)) {                 isTouched = true             }         }     }               override func touchesMoved(_ touches: SetUITouch, with event: UIEvent?) {         if (isTouched == true) {             player.position = (touches.first?.location(in: scene))!         }     }     override func touchesEnded(_ touches: SetUITouch, with event: UIEvent?) {         if isTouched {             isTouched = false         }     }          var timer = Timer()          func startAccelerometers() {        // Make sure the accelerometer hardware is available.        if self.motionManager.isAccelerometerAvailable {           self.motionManager.accelerometerUpdateInterval = 1.0 / 60.0  // 60 Hz           self.motionManager.startAccelerometerUpdates()           // Configure a timer to fetch the data.           self.timer = Timer(fire: Date(), interval: (1.0/60.0),                 repeats: true, block: { (timer) in              // Get the accelerometer data.              if let data = self.motionManager.accelerometerData {                 let x = data.acceleration.x                 let y = data.acceleration.y                 let z = data.acceleration.z                                self.didMove()                 self.update()              }           })           // Add the timer to the current run loop.         RunLoop.current.add(self.timer, forMode: .default)        }     }                func didMove() {                     if motionManager.isAccelerometerAvailable {             // 2             motionManager.accelerometerUpdateInterval = 0.01             motionManager.startAccelerometerUpdates(to: .main) {                 (data, error) in                 guard let data = data, error == nil else {                     return                 }                 // 3                 let currentX = self.player.position.x                 let currentY = self.player.position.y                 self.destX = currentX + CGFloat(data.acceleration.x * 500)                 self.destY = currentY + CGFloat(data.acceleration.y*500)             }         }     }     func update() {         if toggle {             let action = SKAction.moveTo(x: destX, duration: 1)             let action2 = SKAction.moveTo(y: destY, duration: 1)             player.run(action)             player.run(action2)                          if !scene.frame.contains(player.position) {                                  self.player.position = CGPoint(x: SKGameView.frame.size.width/2, y: SKGameView.frame.size.height/2)                                  // self.navigationController?.present(ac, animated: true, completion: nil)             }                          if player.contains(goal) {                 print("work")             }                      }     }      //Never gets called     func didBegin(_ contact: SKPhysicsContact) {          print("asdas")     } }
Posted Last updated
.
Post marked as solved
1 Replies
1.2k Views
so even when i try to create the mostbasic of tables,it still crashed my app throwing a2019-09-30 22:05:39.886579-0400 BHS 2021[6041:478493] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<BHS_2021.studentUpdates 0x7fa13ae2c560> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key classUpate.' and legit the code is//// studentUpdates.swift// Flash Chat//// Created by James Biser on 9/26/19.// Copyright © 2019 James Biser. All rights reserved.//import UIKitclass studentUpdates: UIViewController, UITableViewDelegate, UITableViewDataSource { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } let list = ["update1", "update2"] func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return list.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = list[indexPath.row] return cell } // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. }}the table delgate and daaSource was done through the Storyboards
Posted Last updated
.
Post not yet marked as solved
2 Replies
643 Views
hey!so when i tried to implement 3D Touch or context menus in my application, the app crashes on launch with the context menu active.ive done some testing with the handy breakpoints and noticed that beofre it crashes, it crashed before reaching this block of code if ([shortcutItem.type isEqualToString:shortcutSearch]) { handled = YES; ScoutView *vcq = [[ScoutView alloc] initWithNibName:@"ScoutView" bundle:nil]; self.window.rootViewController = vcq; [self.window makeKeyAndVisible]; }thanks for any help!
Posted Last updated
.
Post not yet marked as solved
0 Replies
379 Views
am i the only one who noticed that the GPS cannot get a accurate pin point of where i am for directions on iPhone XR?
Posted Last updated
.