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 processVideoWithWatermark(video: AVURLAsset, watermark: UIImage, completion: @escaping (Bool) -> Void) { | |
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first | |
let outputPath = documentsURL?.appendingPathComponent("dfyVideo_\(Date().timeStamp).mov") // Needs random time | |
if FileManager.default.fileExists(atPath: video.url.absoluteString) { | |
do { | |
try FileManager.default.removeItem(atPath: video.url.absoluteString) | |
} | |
catch { | |
print ("Error deleting file") |
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 UIKit | |
let stopWords = ["a","about","above","after","again","against","all","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","between","both","but","by","can't","cannot","could","couldn't","did","didn't","do","does","doesn't","doing","don't","down","during","each","few","for","from","further","had","hadn't","has","hasn't","have","haven't","having","he","he","'d","he","'ll","he","'s","her","here","here's","hers","herself","him","himself","his","how","how's","i","'d","'ll","'m","'ve","if","in","into","is","isn't","it","it's","its","itself","let's","me","more","most","mustn't","my","myself","no","nor","not","of","off","on","once","only","or","other","ought","our","ours","ourselves","out","over","own","same","shan't","she","she'd","she'll","she's","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","to","to |
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
fileprivate func createSettingsAlert(_ title: String, message: String) { | |
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "Settings", style: UIAlertActionStyle.default, handler: { (UIAlertAction) in | |
// Use the DispatchQueue.main.async {} block to handle any would be background thread methods. | |
DispatchQueue.main.async { | |
if let appSettings = URL(string: UIApplicationOpenSettingsURLString) { | |
UIApplication.shared.open(appSettings, options: [:], completionHandler: nil) | |
} | |
} | |
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
// Creates the notifcation constant | |
let notification = Notification.Name("NSSystemClockDidChangeNotification") | |
// Add this within your viewDidLoad() | |
NotificationCenter.default.addObserver(self, selector: #selector(handleTimeChange), name: notification, object: nil) | |
// Place this within the view controller where the above is added | |
@objc private func handleTimeChange() { | |
// Add anything you need in here | |
NotificationCenter.default.removeObserver(self, name: notification, object: nil); |
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
fileprivate func getContext() -> NSManagedObjectContext { | |
let appDelegate = UIApplication.shared.delegate as! AppDelegate | |
return appDelegate.persistentContainer.viewContext | |
} | |
func deleteTestObjects(entity: String) { | |
let context = getContext() | |
let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: entity) |
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 currentWeather = JSON(weatherData) // From the API call returned as [String: AnyObject] | |
let current = currentWeather["current"] | |
// Dispatch queue prevents app errors when calling the API data from a background thread | |
DispatchQueue.main.async { | |
self.friendlyUserMessageLabel.text = current["condition"]["text"].stringValue | |
self.windDirectionLabel.text = current["wind_dir"].stringValue | |
self.tempDayLabel.text = "\(current["temp_c"].stringValue)°" | |
} |
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 textViewDidBeginEditing(_ textView: UITextView) { | |
} | |
func textViewDidEndEditing(_ textView: UITextView) { | |
} |