π―
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 | |
| public extension FileManager { | |
| // Returns a URL that points to the document folder of this playground. | |
| static var documentDirectoryURL: URL { | |
| return try! FileManager.default.url( | |
| for: .documentDirectory, | |
| in: .userDomainMask, | |
| appropriateFor: nil, | |
| create: false |
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
| do { | |
| /// Specify a URL where you want to save the myAPIKeys.plist file with proper extension and pathComponent. | |
| let plistURL = URL(fileURLWithPath: "myAPIKeys", relativeTo: FileManager.documentDirectoryURL.appendingPathComponent("MyPlistFolder")).appendingPathExtension("plist") | |
| /// Create an instance of PropertyListEncoder() | |
| /// Specifying outputFormat as `xml` so that you can view it in a source code file format or plist file format. | |
| /// After that, encode your array of keys that you created above | |
| /// And finally, write the encoded Data to your myAPIKeys.plist file. | |
| /// Voila! |
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 documentSubdirectoryURL = URL( | |
| fileURLWithPath: "MyPlistFolder", | |
| relativeTo: FileManager.documentDirectoryURL | |
| ) | |
| try? FileManager.default.createDirectory( | |
| at: documentSubdirectoryURL, | |
| withIntermediateDirectories: false | |
| ) |
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 myKeys = [ | |
| MyKey( | |
| keyName: "facebookAPIKey", | |
| keyValue: "ValueOfMyFacebookAPIKey", | |
| type: .facebook), | |
| MyKey( | |
| keyName: "twitterAPIKey", | |
| keyValue: "ValueOfMyTwitterAPIKey", | |
| type: .twitter)] |
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
| struct MyKey: Codable { | |
| enum Social: String, Codable { | |
| case twitter, facebook | |
| } | |
| init(keyName: String, keyValue: String, type: Social) { | |
| self.apiKeyName = keyName | |
| self.apiKeyValue = keyValue | |
| self.keyType = type | |
| } | |
| let apiKeyName: 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 btnHorizontalFlipTapped(_ sender: UIButton) { | |
| let presentationVC = ThirdViewController() | |
| presentationVC.modalTransitionStyle = .flipHorizontal | |
| present(presentationVC, animated: true, completion: nil) | |
| } | |
| @IBAction func btnPageCurlTapped(_ sender: UIButton) { | |
| let presentationVC = ThirdViewController() | |
| presentationVC.modalTransitionStyle = .partialCurl | |
| present(presentationVC, animated: true, completion: 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
| // MARK: - IBActions | |
| @IBAction func btnNavigateTapped(_ sender: UIButton) { | |
| /// ππΌ Add your animation before you push/pop the view controller | |
| navigationController?.addTransition() | |
| /// ππΌ Don't forget to set the default animated property to FALSE | |
| navigationController?.pushViewController(SecondViewController(), animated: false) | |
| } | |
| @IBAction func btnGoBackTapped(_ sender: UIButton) { | |
| /// ππΌ Add your animation before you push/pop the view controller |
NewerOlder