Skip to content

Instantly share code, notes, and snippets.

View DejanEnspyra's full-sized avatar

Dejan Atanasov DejanEnspyra

View GitHub Profile
@DejanEnspyra
DejanEnspyra / restoreVC.swift
Created February 27, 2018 19:36
Restore Identifier UIViewController (Spotlight)
override func restoreUserActivityState(_ activity: NSUserActivity) {
if activity.activityType == CSSearchableItemActionType, let info = activity.userInfo, let selectedIdentifier = info[CSSearchableItemActivityIdentifier] as? String {
print("Selected Identifier: \(selectedIdentifier)")
}
}
@DejanEnspyra
DejanEnspyra / restore.swift
Created February 27, 2018 19:24
Restore Activity
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
let vc = (window?.rootViewController as! UINavigationController).viewControllers[0]
vc.restoreUserActivityState(userActivity)
return true
}
@DejanEnspyra
DejanEnspyra / deleteItems.swift
Created February 27, 2018 18:55
CoreSpotlight Delete Domains
CSSearchableIndex.default().deleteSearchableItems(withDomainIdentifiers: ["news"]) { (error) in
}
@DejanEnspyra
DejanEnspyra / spotlightIndex.swift
Last active February 27, 2018 18:31
CoreSpotlight indexing
import CoreSpotlight
import MobileCoreServices
func indexSearchableItems(){
//let matches ...
var searchableItems = [CSSearchableItem]()
for match in matches {
let searchItemAttributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeText as String)
searchItemAttributeSet.title = match.title
Privacy Policy
Dejan Atanasov built the 1BET app as a Freemium app. This SERVICE is provided by Dejan Atanasov at no cost and is intended for use as is.
This page is used to inform website visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at 1BET unless otherwise defined in this Privacy Policy.
@DejanEnspyra
DejanEnspyra / biometrics.swift
Last active January 16, 2018 09:59
Face ID and Touch ID Authentication using Swift
func authenticate(){
let context = LAContext()
let reason = "We need this to protect your payments." // add your own message explaining why you need this authentication method
var authError: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, error in
if success {
// User authenticated successfully
} else {
@DejanEnspyra
DejanEnspyra / DetectScene.swift
Created October 31, 2017 16:10
CoreML Place205-GoogLeNet Example (https://theappspace.com)
func scanImage(image: CIImage){
// Load the ML model through its generated class
guard let model = try? VNCoreMLModel(for: GoogLeNetPlaces().model) else {
fatalError("can't load Places ML model")
}
// Create a Vision request with completion handler
let request = VNCoreMLRequest(model: model) { request, error in
guard let results = request.results as? [VNClassificationObservation] else {
fatalError("unexpected result type from VNCoreMLRequest")
@DejanEnspyra
DejanEnspyra / circle.swift
Created October 3, 2017 19:41
Circle Google Maps iOS SDK
func circle(){
let circleCenter = CLLocationCoordinate2D(latitude: 37.35, longitude: -122.0)
let circ = GMSCircle(position: circleCenter, radius: 1000)
circ.map = mapView
}
@DejanEnspyra
DejanEnspyra / polygon.swift
Created October 3, 2017 19:26
Polygon Google Maps iOS SDK
func polygon(){
// Create a rectangular path
let rect = GMSMutablePath()
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0))
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2))
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2))
// Create the polygon, and assign it to the map.
let polygon = GMSPolygon(path: rect)
@DejanEnspyra
DejanEnspyra / polyline.swift
Created October 3, 2017 19:04
Polyline Google Maps iOS SDK
func drawRectange(){
/* create the path */
let path = GMSMutablePath()
path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
path.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0))
path.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2))
path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2))
path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
/* show what you have drawn */