if CLLocationManager.locationServicesEnabled() {
switch(CLLocationManager.authorizationStatus()) {
case .notDetermined, .restricted, .denied:
print("No access")
case .authorizedAlways, .authorizedWhenInUse:
print("Access")
}
} else {
print("Location services are not enabled")
}
let array = ["математика", "физика"]
. В tableViewController №2 создаете переменную которой будете передавать название предмета var name = ""
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Seque" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let destinationVC = segue.destination as! SecondTableViewController
destinationVC.name = self.array[(indexPath as NSIndexPath).row]
}
}
}
// create and add a camera to the scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
//let cameraRoot = SCNNode()
cameraNode.position = SCNVector3(x: 0, y: 10, z: 20)
//cameraRoot.addChildNode(cameraNode)
scene.rootNode.addChildNode(cameraNode)
// setup a target object
let sphere = SCNSphere(radius: 0)
let sphereNode = SCNNode(geometry: sphere)
scene.rootNode.addChildNode(sphereNode)
// put a constraint on the camera
let targetNode = SCNLookAtConstraint(target: sphereNode)
targetNode.isGimbalLockEnabled = true
cameraNode.constraints = [targetNode]
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDetailsSegue" && searchController.active {
if let indexPath = self.resultsController.tableView.indexPathForSelectedRow {
let destinationVC = segue.destinationViewController as! DetailsViewController
destinationVC.ralImage = self.ralImages[indexPath.row]
destinationVC.ralName = self.filteredRal[indexPath.row]
} else if let indexPath = self.tableView.indexPathForSelectedRow {
let destinationVC = segue.destinationViewController as! DetailsViewController
destinationVC.ralImage = self.ralImages[indexPath.row]
destinationVC.ralName = self.ralNames[indexPath.row]
}
}
if segue.identifier == "showDetailsSegue" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let destinationVC = segue.destinationViewController as! DetailsViewController
destinationVC.ralImage = self.ralImages[indexPath.row]
destinationVC.ralName = self.ralNames[indexPath.row]
}
}
}
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(MainTableViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
var movingNode : SKNode?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch = touches.first
let touchLocation = touch!.locationInNode(self)
let node = self.nodeAtPoint(touchLocation)
if (node.name == "circle") {
movingNode = node
let moveAction = SKAction.moveTo(touchLocation, duration: 0)
figureUser.runAction(moveAction)
}
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch = touches.first
let touchLocation = touch!.locationInNode(self)
let moveAction = SKAction.moveTo(touchLocation, duration: 0)
figureUser.runAction(moveAction)
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
switch editingStyle {
case .Delete:
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let context:NSManagedObjectContext = appDel.managedObjectContext
context.deleteObject(items[indexPath.row] as NSManagedObject)
items.removeAtIndex(indexPath.row)
do{
try context.save()
}catch{
print("Error, data not saved!")
}
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
default:
return
}
}
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var Name: UITextField!
let saveName = NSUserDefaults.standardUserDefaults()
@IBAction func HideKeyboardName(sender: UITextField) {
saveName.setObject(Name.text, forKey: "Name")
}
override func viewDidLoad() {
super.viewDidLoad()
if let text = saveName.stringForKey("Name") {
Name.text = text
}
}
}