Parsing URL Parameters with Swift
Here is an extension you can use in your Swift (v4) projects that makes it easy to parse parameters from a url. Given a url like, "http://example.com/?x=1&y=2", you can extract the x and y parameters into a key, value data structure. Here is the s...
Written by Sean Behan on 09/23/2018
How to Chunk Large Files in Swift
How to Chunk Large Files in Swift (4.1) It takes a bit of work but this is the solution I found that finally worked, thanks to this Stack Overflow thread https://stackoverflow.com/questions/46464177/split-data-in-chunks-and-upload-to-server The example ...
Written by Sean Behan on 09/15/2018
How to Get GPS Location Information from Address String with Swift and iOS CLGeocoder
You can use CLGeocoder geocodeAddressString method. It will return an array of CLPlacemark objects that contain gps coords and city, location info. let address = "Burlington, Vermont" CLGeocoder().geocodeAddressString(address, completionHandler...
Written by Sean Behan on 06/11/2018
How to Get GPS Location Information from a Photo or Movie with Swift and UIImagePickerController
This code assumes you're using the UIImagePickerController. If not you will need to get an image url another way. But, If you are using UIImagePickerControllerDelegate then it will supply the asset's url in the `info` dictionary . From the asset's url...
Written by Sean Behan on 06/11/2018
How to Dynamically Call a Method from a String in Swift
You have to subclass NSObject class Car : NSObject { func drive(){ print("Driving..") } } let car : Car = Car() car.perform(NSSelectorFromString("drive"))
Written by Sean Behan on 06/09/2018
How to Check if Your iOS or MacOS App is Connected to the Internet
Is your app connected to the internet? You can use this standalone class to check! There are no dependencies so you can copy/paste it into your project without needing to install another framework. With this class it's as simple as running `Reachabili...
Written by Sean Behan on 06/08/2018
How to Flush or Erase Cache of Your XCode iOS or MacOS Cocoa App
If you're working with an XCode application, either iOS or MacOS, and want to do a completely clean build and delete the cache, it's simple. Execute this command from the command line.. defaults delete your.apps.bundle.id Where "your.apps.bundl...
Written by Sean Behan on 06/08/2018
How to Find the Directory Locations Your XCode App Uses
You can add this snippet to your application, say for instance in your `viewDidLoad` function, that will print to the XCode console, the location of your app while it's being developed. // prints the location of asset my-added-file.txt that you've ad...
Written by Sean Behan on 06/06/2018
Extension for Encoding and Decoding Strings in Base64 in Swift
Here is an extension to base 64 encode and decode strings in Swift (3) extension String { func fromBase64() -> String? { guard let data = Data(base64Encoded: self) else { return nil } return String(data: data, encoding: ....
Written by Sean Behan on 05/02/2018