Xcode Use UIRefreshControl in any UIScrollView(UICollectionView, WebView) Apple documentation shows us how we can use an UIRefreshControl in an UITableViewController, but do you know, we can add it to any UIScrollView ? let refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: #selector(handleRefresh), for: .valueChanged) scrollView.addSubview(refreshControl) In a similar way, we can add UIRefreshControl to a WKWebView. let...
Tips How to create empty commits to test CI & CD or anything else? Sometimes we need to make empty commits on some testing branch so that we can trigger various kinds of things like Jenkins build etc. So, here the way to make an empty commit which will trigger a push event on GitHub/GitLab, etc. This is more convenient than adding spaces...
Tips Generate Strongly-Typed Swift/Obj-C Data Models directly from JSON Quicktype [https://app.quicktype.io] generate Strongly-Typed Swift/Objective-C Data Models from JSON, Schema, and GraphQL. You just need to paste your JSON string in left side text box. Generated models code has comments at the top with a code sample that shows how to convert a JSON string to...
Tips How to create a Strongly Typed Info.plist? You can easily access info.plist strongly typed by create a struct this way - struct InfoPlist<T> { static func get(for key: String) -> T? { return Bundle.main.infoDictionary?[key] as? T } static subscript(key: String) -> T? { return get(for: key) } } Now you can...
Tips An easy way to maintain UserDefaults key You can use #function literal to get the property name as UserDefault key. In the following example, #function will get replaced by accessToken. Be aware, changing the property names may break functionality for the existing users. extension UserDefaults { var accessToken: String? { get { return string(forKey: #function) } set { set(newValue, forKey:...
Tips The xed - Xcode Text Editor Invocation Tool If you are in your Xcode project folder and your project has both a workspace( .xcworkspace) and a project(.xcodeproj) the file then you can use following command to open workspace in Xcode from your terminal - xed . If your project only has a project(.xcodeproj) the file then the...
Xcode Where to find Project Build Settings Documentation? Do you know Xcode's project build setting has documentation? Just press ⌥ (option) + Double Click for complete documentation or open Quick Help Inspector....
Xcode How to Add Function Documentation in Xcode? You can use ⌥ + ⌘ + / (option + command + ) to add function documentation....
Tips How to clean the iOS app launch screen cache? You might have noticed when you tried to change something in the launch screen on the iOS application, you still see the old launch screen. Because the system caches launch images and it's not cleared even after deleting the application. For cleaning the launch screen, all you have...
Tips How to do Git Blame in Xcode? If you work with a team, do you ever need to know who added this horrible bug? There are two ways to do Git Blame in Xcode. 1. Check the last change for a specific line To check the last change for a specific line, place the cursor on the...
Tips How to Open a File in Specific Xcode Position? In Xcode, you can open a file in various ways, you can open a file in the standard editor, in a new or existing assistant editor, in a new or existing tab, or in a new window. Here's how you can decide about this. When you clicking on...
Tips Xcode - How to Quick Jump on Specific Line Number? You might know, command + shift + o opens the "Open quickly" dialog, where you can quickly find and open files that contain the text you enter. But, If you type a line number after a file name in then open dialog jump straight to the that line number of...
Tips How to Access Document Directory Content in Files App? From iOS 11, If you set LSSupportsOpeningDocumentsInPlace to YES and UIFileSharingEnabled to YES in your Info.plist, you can access your application Documents directory in the Files application. <key>LSSupportsOpeningDocumentsInPlace</key> <true/> <key>UIFileSharingEnabled</key> <true/> For debugging...
Xcode How to set UserDefault Key Value from Launch Argument? This is the best hidden feature of UserDefaults. If you pass a UserDefault key and value as a launch argument this will set new value for that key. You can use this trick to override current value for any key. This will help you a lot in debugging. Here the...
Tips Test your localization string with NSDoubleLocalizedStrings You can use NSDoubleLocalizedStrings as a launch argument to double the length of all of your NSLocalizedStrings to easily test your UI for internationalization purposes. Here the side by side demo -...