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 scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
if let userID = UserDefaults.standard.object(forKey: "userId") as? String { | |
let appleIDProvider = ASAuthorizationAppleIDProvider() | |
appleIDProvider.getCredentialState(forUserID: userID) { (state, error) in | |
DispatchQueue.main.async { | |
switch state | |
{ | |
case .authorized: // valid user id |
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
extension ViewController: QLPreviewControllerDelegate { | |
func previewController(_ controller: QLPreviewController, editingModeFor previewItem: QLPreviewItem) -> QLPreviewItemEditingMode { | |
return .createCopy | |
} | |
func previewController(_ controller: QLPreviewController, didSaveEditedCopyOf previewItem: QLPreviewItem, at modifiedContentsURL: URL) { | |
let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! | |
let currentTimeStamp = String(Int(NSDate().timeIntervalSince1970)) |
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 FirebaseMLNaturalLanguage | |
struct ContentView: View { | |
@State var name: String = "" | |
@State var languageIdentified: String = "" | |
var body: some View { | |
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 FirebaseMLNLSmartReply | |
struct ContentView: View { | |
@State var name: String = "" | |
@State var smartReply: String = "" | |
var body: some View { | |
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 FirebaseMLNLTranslate | |
struct ContentView: View { | |
@State var name: String = "" | |
@State var languageTranslate: String = "" | |
var body: some View { | |
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 createLayoutDiffSection() -> UICollectionViewLayout { | |
let layout = UICollectionViewCompositionalLayout { (sectionIndex: Int, | |
layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in | |
var columns = 1 | |
switch sectionIndex{ | |
case 1: | |
columns = 3 | |
case 2: | |
columns = 5 |
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 parsingOptions = MLDataTable.ParsingOptions(containsHeader: Bool = true, delimiter: String = ",", | |
comment: String = "", escape: String = "\\", | |
doubleQuote: Bool = true, quote: String = "\"", | |
skipInitialSpaces: Bool = true, missingValues: [String] = ["NA"], | |
lineTerminator: String = "\n", selectColumns: [String]? = nil, | |
maxRows: Int? = nil, skipRows: Int = 0) | |
var data = try MLDataTable(contentsOf: URL(fileURLWithPath: "/your/path/here"), options: parsingOptions) | |
print(data.size) //5043 rows and 28 columns in our IMDB dataset |
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
struct ContentView : View { | |
@EnvironmentObject var observer : SwipeObserver | |
var body : some View{ | |
GeometryReader{geo in | |
ZStack{ | |
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 Introspect | |
struct ContentView : View { | |
@State var text = "" | |
var body: some View { | |
VStack { | |
TextField("Enter some text", text: $text) |
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
struct Anything<Wrapper : UIView>: UIViewRepresentable { | |
typealias Updater = (Wrapper, Context) -> Void | |
var makeView: () -> Wrapper | |
var update: (Wrapper, Context) -> Void | |
init(_ makeView: @escaping @autoclosure () -> Wrapper, | |
updater update: @escaping (Wrapper) -> Void) { | |
self.makeView = makeView | |
self.update = { view, _ in update(view) } |