This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, canHandle session: UIDropSession) -> Bool { | |
if session.canLoadObjects(ofClass: UIImage.self) { | |
return true | |
} else { | |
return false | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool { | |
if secondaryViewController is PlaceholderViewController { | |
return false | |
} else { | |
return true | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MARK:- Accessibility | |
override var accessibilityLabel: String? { | |
get { | |
return activityTypeLabel.accessibilityLabel | |
} | |
set { } | |
} | |
override var accessibilityValue: String? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let record = CKRecord(recordType: "MyType", recordID: recordID) | |
record["title"] = "name" as CKRecordValue? | |
record["price"]= 1 as CKRecordValue? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let database = CKContainer.default().privateCloudDatabase | |
let operation = CKModifyRecordsOperation(recordsToSave: recordsToSave, recordIDsToDelete: recordIDsToDelete) | |
operation.modifyRecordsCompletionBlock = { (records, recordIDs, error) in | |
//TODO: | |
} | |
operation.database = database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let iconName = "sampleicon" | |
UIApplication.shared.setAlternateIconName(iconName) { (error) in | |
if let e = error { | |
print(e) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SceneKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var sceneView: SCNView! | |
override func loadView() { | |
super.loadView() | |
let scene = SCNScene() | |
self.sceneView.scene = scene |