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 commentButtonSlideIn(fromRight:Bool = true){ | |
if(fromRight){ | |
myButton.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: 15).isActive = true | |
myButton.frame.origin.x = UIScreen.main.bounds.width | |
}else{ | |
myButton.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: -15).isActive = true | |
myButton.frame.origin.x = -80 | |
} | |
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 Foundation | |
extension String { | |
var withoutPunctuations: String { | |
return self.components(separatedBy: CharacterSet.punctuationCharacters).joined(separator: "") | |
} | |
} | |
let originalStr:String = "hello, (Nice to- meet 한국 école %&$you all. 123 ! Давай العربية 😀" |
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
extension UIViewController { | |
func resizeHeaderView(tableView:UITableView) { | |
guard let headerView = tableView.tableHeaderView else { | |
return | |
} | |
headerView.setNeedsLayout() | |
headerView.layoutIfNeeded() | |
tableView.sectionHeaderHeight = UITableView.automaticDimension |
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
asyncfunction(){ result in | |
async2func(){ result in | |
async3func() { result in | |
//... | |
} | |
} | |
} |
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 asyncQueue = DispatchGroup() | |
for person in people{ | |
asyncQueue.enter() | |
// "checkIdentity" is a Async function which takes networking resource and consume a bit of time. | |
self.checkIdentity(person) { (err) in | |
if(err != 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 logg(_ object: Any, filepath:String = #file, functionname:String = #function, linenumber:Int = #line){ | |
#if DEBUG | |
let filename = (filepath as NSString).lastPathComponent | |
print("🔨", filename,">", functionname,">", linenumber) | |
print(object) | |
// 🔨 ViewController.swift > myFunction(param:) > 36 | |
#endif | |
} |
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 Foundation | |
import Firebase | |
import FirebaseFunctions | |
import FirebaseFirestoreSwift | |
struct MyCollection: Codable { | |
var _id:String? | |
var title:String | |
var description:String? | |
var keywords:[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
@IBAction func onSave(_ sender: UIBarButtonItem) { | |
if(self.sentence == nil){ | |
print("Insufficient Sentence Data") | |
addSoundButton.shake() | |
return | |
} | |
} |
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
extension UIView{ | |
// ... | |
func shake(){ | |
let animation = CAKeyframeAnimation(keyPath: "transform.translation.x") | |
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) | |
animation.duration = 0.6 | |
animation.values = [-20.0, 20.0, -20.0, 20.0, -10.0, 10.0, -5.0, 5.0, 0.0 ] | |
self.layer.add(animation, forKey: "shake") |
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 functions = Functions.functions() | |
functions.useFunctionsEmulator(origin: "http://localhost:5001") | |
functions.httpsCallable("generateSound").call() { (result, error) in | |
if let error = error as NSError? { | |
if error.domain == FunctionsErrorDomain { | |
let code = FunctionsErrorCode(rawValue: error.code) | |
let message = error.localizedDescription | |
let details = error.userInfo[FunctionsErrorDetailsKey] | |
print(code ?? "", message , details ?? "") |