You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
Tanner Bennett
NSExceptional
I build cool things so you can build cooler things. Lover of objc, Swift, and TypeScript. Work account: @tannerbennett-tinder
Contact me on Twitter.
Given a path to a folder, replaces all occurrences of `snake_case` words (ignoring `ALL_CAPS` and `dispatch_foo` and `objc_foo`) with their `camelCase` equivalent.
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
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
Add the following to ~/.bash_profile (create the file if it does not exist by typing touch ~/.bash_profile into terminal. The touch command simply creates a file if it does not exist):
A program that adds the UUID of the current installation of Xcode (in /Applications/Xcode.app) to every Xcode plug-in's Info.plist. Does nothing if the plug-in already contains the current UUID.
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
An example of how to use Mantle in Swift, assuming you have a bridging header that #imports Mantle.h
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
A quick and dirty example of loading classes at runtime
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
A UIView subclass that fades away more the harder you press on it, and eventually disappears if you press hard enough. iOS 9 only, of course.
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
An example of an immutable property with mutable storage.
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
An example of how to use a private class from Swift. It's not pretty, but it isn't too bad.
Using private Objective-C classes from Swift
In Objective-C, if you want to make use of one of Apple's internal classes, all you have to do is declare the class's interface with the methods you want to use. From there you can create instances of the class by using the NSClassFromString function to obtain a reference to the class object, like so:
In Swift, this is not so easy. Referencing the type of the "hollow" Objective-C class interface anywhere in Swift code makes the compiler query the class for type information that is not known at compile time. This presents a huge problem. You cannot dynamically initialize a type either. Though, it seems the following code used to work at one point:
First uploaded to storage.googleapis.com/snallery-m/a1ca9af0-be6b-4874-a6a1-8e30823ae0cf/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with the following query parameters:
GoogleAccessId: GOOGMR536EIHHSJL2KAK
Expires: 14679XXXXX
Signature: base64 string
The thumbnail is uploaded to storage.googleapis.com/snallery-t/a1ca9af0-be6b-4874-a6a1-8e30823ae0cf/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy with the same queries. HTTP method is PUT for both