This file contains 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 SwiftUI | |
import WebKit | |
typealias WebCallBack = ((String?) -> Void)? | |
class MyWKDelegate: NSObject, WKNavigationDelegate { | |
private var webCallBack: WebCallBack = nil | |
init(webCallBack: WebCallBack) { | |
self.webCallBack = webCallBack |
This file contains 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 SwiftUI | |
struct KeyPad: View { | |
@Binding var string: String | |
var action: () -> Void | |
var body: some View { | |
VStack { | |
KeyPadRow(keys: ["1", "2", "3"]) | |
KeyPadRow(keys: ["4", "5", "6"]) | |
KeyPadRow(keys: ["7", "8", "9"]) |
This file contains 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
public struct SkeletonGradientAnimationView: View { | |
@State var offset: CGFloat = 0 | |
public var body: some View { | |
ZStack { | |
GeometryReader { reader in | |
let largestSide = reader.size.width > reader.size.height ? reader.size.width : reader.size.height | |
LinearGradient( |
This file contains 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 Foundation | |
extension UIView{ | |
func border(color : UIColor, side : String, width : CGFloat) | |
{ | |
var borderFrame = CGRect.zero | |
switch side { | |
case "left": | |
borderFrame = CGRect(x: 0.0, y: 0.0, width: width, height: self.frame.size.height) |
This file contains 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 backgroundQ = DispatchQueue.global(attributes: .qosDefault) | |
let group = DispatchGroup() | |
var someData:[Data] = [] | |
for number in 0..<n { | |
group.enter() | |
backgroundQ.async(group: group, execute: { | |
if number > 50 { | |
fill.append(number) | |
} |
This file contains 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
// | |
// ContactsManager.swift | |
// main | |
// | |
// Created by Nero Wolfe on 14/07/16. | |
// Copyright © 2016 Incoding. All rights reserved. | |
// | |
import UIKit | |
import Contacts |
This file contains 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 showMessage(message : String, delay : NSTimeInterval, color : UIColor, completion: boolClosure?) | |
{ | |
dispatch_async(self.GlobalMainQueue) | |
{ | |
guard let window = appDelegate.window else | |
{ | |
completion!(result: false,error: nil) | |
return | |
} | |
This file contains 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 spotLighIndexingForContact(contact: MainContact) -> AnyObject | |
{ | |
if #available(iOS 9, *) { | |
let attributeSet : CSSearchableItemAttributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeImage as String) | |
let name : String = contact.firstname + " " + contact.lastname | |
attributeSet.title = name | |
attributeSet.contentDescription = "Main Contact" | |
This file contains 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: Address Book methods | |
func createAddressBook() -> Bool { | |
if self.adbk != nil { | |
return true | |
} | |
var err : Unmanaged<CFError>? = nil | |
let adbk : ABAddressBook? = ABAddressBookCreateWithOptions(nil, &err).takeRetainedValue() | |
if adbk == nil { | |
print(err) |
This file contains 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
f you are on OS X 10.8 or iOS 6 you can use the new NSUUID class to generate a string UUID, without having to go to Core Foundation: | |
NSString *uuidString = [[NSUUID UUID] UUIDString]; | |
// Generates: 7E60066C-C7F3-438A-95B1-DDE8634E1072 | |
But mostly, if you just want to generate a unique string for a file or directory name then you can use NSProcessInfo's globallyUniqueString method like: | |
NSString *uuidString = [[NSProcessInfo processInfo] globallyUniqueString]; | |
// generates 56341C6E-35A7-4C97-9C5E-7AC79673EAB2-539-000001F95B327819 | |
It's not a formal UUID, but it is unique for your network and your process and is a good choice for a lot of cases. |
NewerOlder