Skip to content

Instantly share code, notes, and snippets.


Rui Peres RuiAAPeres

Block or report user

Report or block RuiAAPeres

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Greetings, NSHipsters!

As we prepare to increment our NSDateComponents -year by 1, it's time once again for NSHipster end-of-the-year Reader Submissions! Last year, we got some mind-blowing tips and tricks. With the release of iOS 7 & Mavericks, and a year's worth of new developments in the Objective-C ecosystem, there should be a ton of new stuff to write up for this year.

Submit your favorite piece of Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!

Here are a few examples of the kind of things I'd like to see:

  • Using NSStringFromSelector(@selector()) as a safer way to do KVC / KVO / NSCoding.
  • Panic's [rather surprising discovery about the internals of the Lightning Digital AV Adapter](
d-ronnqvist / Thoughts on removedOnCompletion in
Last active May 12, 2019
What I think is wrong with the Spark Recording Circle code and why
View Thoughts on removedOnCompletion in

There was [a tweet][tweetSoto] a couple of days ago that resulted in a discussion/question about what it wrong with the usage of removedOnCompletion = NO in the [SparkRecordingCircle code][code] for that [Subjective-C post][post].

We all kept saying that the explanation doesn't fit in a tweet, so here is my rough explanation about the issues.

But, let me first say that I think that the Subjective-C articles are reallt cool and useful to learn from. This is trying to reason about the general usage of removedOnCompletion = NO, using that code as an example, since that was what was discussed on twitter.

The root problem, as [Nacho Soto pointed out][rootProblem], is that removedOnCompletion = NO in combination with fillMode = kCAFillModeForwards is almost always used when you are not updating the model layer. This means that after the animation has finished, what you see on screen is not reflected in the property of the layer. The biggest issue that this can cause is that all the

kongtomorrow / gist:e153a95907d188fb078a
Created Jun 10, 2014
@auto_closure for control over evaluation
View gist:e153a95907d188fb078a
func myAnd(lhs : Bool, rhs : @auto_closure () -> Bool) -> Bool {
if lhs {
return rhs()
} else {
return false
func logAndBool(val : Bool) -> Bool {
println("evaluating and returning \(val)!")
View repmin.swift
// This accompanies
import UIKit
// Unfortunately, we need Box
public class Box<T> {
public let unbox: T
public init(_ value: T) { self.unbox = value }
JadenGeller / List Comprehension.swift
Last active Mar 17, 2018
Nondeterministic Computation with Arrays
View List Comprehension.swift
// In languages like Python and Haskell, we can write list comprehension syntax like
// super simply to generate complex lists. Below, for example, we find all numbers that are
// the product of two sides of a triangle.
// [a * b | a <- [1..10], b <- [1..10], c <- [1..10], a * a + b * b == c * c]
// Why is this called nondeterministic computation? Because we essentially try ALL possible combinations
// of these values (a,b) and--you can imagine--run them all simultanously and get the result that matches the predicate.
// Now, obviously, this doesn't all happen at the same time, but that's the idea behind the nondeterminism.
// Let's examine how we can get a similiar result in Swift! We'll start super simple and work
View Signal+Extensions.swift
// Signal+Extensions.swift
// Khan Academy
// Created by Nacho Soto on 10/1/15.
// Copyright © 2015 Khan Academy. All rights reserved.
import ReactiveCocoa
JaviSoto / NibInstantiable.swift
Last active Sep 1, 2016
RSwift Fabric Extensions
View NibInstantiable.swift
import UIKit
import Rswift
struct NibResource: NibResourceType {
let name: String
let bundle: NSBundle
init(name: String, bundle: NSBundle = NSBundle.mainBundle()) { = name
self.bundle = bundle
RuiAAPeres / covariance_contravariance.swift
Last active Sep 16, 2019
Covariance and Contravariance in Swift
View covariance_contravariance.swift
import UIKit
// Based on
// > Denotes "a subtype of"
// UIButton > UIView > UIResponder > NSObject
// e.g. `UIButton` is a subtype of `UIView`
// This means that any function that takes a `UIView`, can receive a `UIButton`:
View animationcurves.swift
// ContentView.swift
// AnimationTimingCurve
// Created by Chris Eidhof on 25.09.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
import SwiftUI
You can’t perform that action at this time.