Skip to content

Instantly share code, notes, and snippets.

func tableView(_ tableView: UITableView, canHandle session: UIDropSession) -> Bool {
if session.canLoadObjects(ofClass: UIImage.self) {
return true
} else {
return false
}
}
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if tabBarController.selectedViewController == viewController, let split = viewController as? UISplitViewController {
if split.isCollapsed {
if let navigation = split.viewControllers.first as? UINavigationController {
navigation.popToRootViewController(animated: true)
}
} else if split.displayMode == .primaryHidden {
let mode = split.preferredDisplayMode
split.preferredDisplayMode = mode
}
func splitViewController(_ splitViewController: UISplitViewController, separateSecondaryFrom primaryViewController: UIViewController) -> UIViewController? {
if let navigation = primaryViewController as? UINavigationController, navigation.viewControllers.count == 1 {
return UIStoryboard(name: "Placeholder", bundle: nil).instantiateInitialViewController()
} else {
return nil
}
}
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
if secondaryViewController is PlaceholderViewController {
return false
} else {
return true
}
}
//MARK:- Accessibility
override var accessibilityLabel: String? {
get {
return activityTypeLabel.accessibilityLabel
}
set { }
}
override var accessibilityValue: String? {
let record = CKRecord(recordType: "MyType", recordID: recordID)
record["title"] = "name" as CKRecordValue?
record["price"]= 1 as CKRecordValue?
let database = CKContainer.default().privateCloudDatabase
let operation = CKModifyRecordsOperation(recordsToSave: recordsToSave, recordIDsToDelete: recordIDsToDelete)
operation.modifyRecordsCompletionBlock = { (records, recordIDs, error) in
//TODO:
}
operation.database = database
let iconName = "sampleicon"
UIApplication.shared.setAlternateIconName(iconName) { (error) in
if let e = error {
print(e)
}
}
private func firstDayOfWeek(date:Date) -> Date {
let cal = Calendar.current
let firstWeekDay = cal.firstWeekday
let thisWeekDay = cal.dateComponents([.weekday], from: date).weekday!
var diff = thisWeekDay - firstWeekDay
if thisWeekDay < firstWeekDay {
diff += cal.weekdaySymbols.count
}
diff = -1 * diff
let firstDay = cal.date(byAdding: .day, value: diff, to: date)!
import UIKit
import SceneKit
class ViewController: UIViewController {
@IBOutlet weak var sceneView: SCNView!
override func loadView() {
super.loadView()
let scene = SCNScene()
self.sceneView.scene = scene