Skip to content

Instantly share code, notes, and snippets.

@davbeck
davbeck / AssociatedProperty.swift
Created February 10, 2020 17:53
Swift friendly wrapper around associated objects.
import ObjectiveC
extension objc_AssociationPolicy {
public static let retain = objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN
public static let retainNonatomic = objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC
public static let copy = objc_AssociationPolicy.OBJC_ASSOCIATION_COPY
public static let copyNonatomic = objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC
public static let assign = objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN
}

Workflow

We use Jira to track bugs and features and git flow to track changes to the code. The workflow for a ticket goes as follows:

  1. The developer moves a ticket into the "In Progress" column, assigning it to themselves.

  2. The developer creates a new branch off of develop (or another feature branch if necessary) naming it feature/REALM-XXXXX-description where "REALM-XXXXX" is the ticket number in Jira and "description" is a 1-3 word description of the ticket.

  3. Any changes needed to fulfill the ticket are performed in 1 or more commits. Each commit should start with the ticket number, as in REALM-XXXXX Added link to make a gift. Prefixing the ticket number here causes the commit to appear in Jira.

@davbeck
davbeck / README.md
Last active August 29, 2015 13:57
TNKPropertyKey

It's become common practice to use an @selector for associated objects. This is useful because not only are SELs guaranteed to have a unique address, but because as of Xcode 5, Xcode will warn you when you use a selector that it does not know about. Meaning that it is somewhat protected against spelling mistakes.

This can also be useful when using string keys. For things like state restoration, where you want a key for a given property, you can use the selector for the getter, and get a string from that. Xcode will autocomplete the name for you, and will warn you if you misspell it.

- (void)encodeRestorableStateWithCoder:(NSCoder *)coder
{
    [super encodeRestorableStateWithCoder:coder];
    
 [coder encodeObject:self.feedID forKey:TNKPropertyKey(feedID)];