Skip to content

Instantly share code, notes, and snippets.

View zenangst's full-sized avatar
🥪
Reminiscing about vacation

Christoffer Winterkvist zenangst

🥪
Reminiscing about vacation
View GitHub Profile
def dark_knight?
if article.picture
article.picture.dark
else
nil
end
end

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](http://www.panic.com/blog/the-lightning-di
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon</string>
@zenangst
zenangst / XcodePlugin.sh
Last active October 18, 2016 05:14
XcodePlugin.sh
#!/bin/sh
#ID='A16FF353-8441-459E-A50C-B071F53F51B7' # Xcode 6.2
#ID='992275C1-432A-4CF7-B659-D84ED6D42D3F' # Xcode 6.3
ID='7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90' #Xcode 6.4
#ID='AABB7188-E14E-4433-AD3B-5CD791EAD9A3' # Xcode 7.0
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
(lldb) bt
* thread #1: tid = 0x2276c8, 0x000000011265c75a libswiftFoundation.dylib`static Foundation.IndexPath._unconditionallyBridgeFromObjectiveC (Swift.Optional<__ObjC.NSIndexPath>) -> Foundation.IndexPath + 42, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x000000011265c75a libswiftFoundation.dylib`static Foundation.IndexPath._unconditionallyBridgeFromObjectiveC (Swift.Optional<__ObjC.NSIndexPath>) -> Foundation.IndexPath + 42
frame #1: 0x000000010f7c1028 Spots`@objc Delegate.tableView(UITableView, didEndDisplaying : UITableViewCell, forRowAt : IndexPath) -> () + 88 at Delegate+iOS+Extensions.swift:0
frame #2: 0x0000000110a43ba9 UIKit`-[UITableView _reuseTableViewCell:withIndexPath:didEndDisplaying:] + 294
frame #3: 0x0000000110a3fca4 UIKit`-[UITableView _updateVisibleCellsNow:isRecursive:] + 2410
frame #4: 0x0000000110a74f9f UIKit`-[UITableView _performWithCachedTraitCollection:] + 110
frame #5: 0x0000000110a5bfc8
@zenangst
zenangst / ContentFactory.swift
Created May 1, 2017 19:47
From inspiration to production, Part 2
import Spots
enum MainContentType: String {
case details, reception, related
}
class ContentFactory {
func sideComponents() -> [ComponentModel] {
let posterComponent = ComponentModel(
@zenangst
zenangst / From-inspiration-to-production-part2-example1.swift
Last active May 9, 2017 18:52
From inspiration to production, Part 2 - Example 1
private func createRelatedComponents() -> [ComponentModel] {
let infoComponent = ComponentModel(
header: Item(title: "Star Wars films and television series", kind: Spots.Identifier.header),
kind: .grid,
layout: Layout(span: 1, inset: Inset(top: 0, left: 20, bottom: 30, right: 20)),
items: [Item(text: "The Star Wars films include two complete trilogies: the original trilogy released between 1977 and 1983, and the prequel trilogy released between 1999 and 2005. A third trilogy that follows the first two began in 2015. Other films have taken or will take place between the trilogy films. There have also been several Star Wars television series and television movies, with the first being released in 1978.", kind: Spots.Identifier.info)]
)
let relatedComponent = ComponentModel(
header: Item(title: "Related movies", kind: Spots.Identifier.header),
@zenangst
zenangst / ShouldAnimate.swift
Created February 13, 2018 17:53
Syncing UIView animations - Should animate example
let shouldAnimate = !(subviewsInLayoutOrder.flatMap{ $0.layer.animationKeys() }.isEmpty)
@zenangst
zenangst / RunAlgorithmAnimated.swift
Created February 13, 2018 17:55
Syncing UIView animations - Run algorithm with animation
let options: UIViewAnimationOptions = [.allowUserInteraction, .beginFromCurrentState]
UIView.animate(withDuration: 2.5, delay: 0.0, options: options, animations: {
self.runLayoutSubviewsAlgorithm()
})
@zenangst
zenangst / ClientSideCodeExample.swift
Created February 13, 2018 17:57
Syncing UIView animations - Client side example
let options: UIViewAnimationOptions = [.allowUserInteraction, .beginFromCurrentState]
UIView.animate(withDuration: 0.4, delay: 0.0, options: options, animations: {
self.headerViewController.view.frame.size.height = 120
self.contentViewController.view.frame.size.height = 320
self.moreViewController.view.frame.size.height = 210
})