Skip to content

Instantly share code, notes, and snippets.

@xjones
xjones / TransitionController.h
Created November 26, 2011 03:48
TransitionController for animating iOS view controller transitions w/o a controller stack
//
// TransitionController.h
//
// Created by XJones on 11/25/11.
//
#import <UIKit/UIKit.h>
@interface TransitionController : UIViewController
@jcaraballo
jcaraballo / git-branch-between-different-repositories.md
Created March 6, 2012 01:05
How to fork a github repository in bitbucket

#Create bitbucket branch

##Create local branch

$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
  master
* sync
@matteogobbi
matteogobbi / cancel_dispatcher_by_flag.m
Last active August 29, 2015 13:57
Block execution by a flag of blocks queued with dispatch_after.
//Flag
_isCancelled = @(NO);
//Create a queue
dispatch_queue_t queue = dispatch_queue_create("queue", NULL);
//Insert 3.000 blocks executed with a delay of 1 sec
for (int i=0; i<3000; i++) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1* NSEC_PER_SEC)), queue, ^(void){
if(![_isCancelled boolValue])
@idStar
idStar / AppDelegate.m
Created September 13, 2014 19:52
A way to exit full app launch mechanics when you're simply invoking the XCTest target and want to speed things up.
#pragma mark - XCTest Support
static BOOL isRunningTests(void) __attribute__((const));
/**
We need a mechanism to detect if we have been invoked / are running from a unit test.
If we are, we'll want to exit early instead of doing all kinds of view controller setup.
This function determines based on the environment, if we're running in a unit test process,
such as XCTest.

ASCIIwwdc Viewing Statistics

June 1, 2014 – September 15, 2014

Percentage of total visits for sessions among the top 100 pages on ASCIIwwdc.

Initial Takeaways

  • Vast majority of views for 2014 sessions, as might be expected
  • Top 6 most-watched session all involve view controllers & Interface Builder (accounting for 1/4 of total traffic)
  • "What's New in X" sessions are extremely popular
@jackreichert
jackreichert / getKeyVals
Last active March 19, 2020 07:12
This is a swift extension for NSURL so you can parse the query string and get back a dictionary of the variables.
extension NSURL {
func getKeyVals() -> Dictionary<String, String>? {
var results = [String:String]()
var keyValues = self.query?.componentsSeparatedByString("&")
if keyValues?.count > 0 {
for pair in keyValues! {
let kv = pair.componentsSeparatedByString("=")
if kv.count > 1 {
results.updateValue(kv[1], forKey: kv[0])
}
@Ashton-W
Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@oleganza
oleganza / async_swift_proposal.md
Last active May 12, 2023 10:06
Concrete proposal for async semantics in Swift

Async semantics proposal for Swift

Modern Cocoa development involves a lot of asynchronous programming using blocks and NSOperations. A lot of APIs are exposing blocks and they are more natural to write a lot of logic, so we'll only focus on block-based APIs.

Block-based APIs are hard to use when number of operations grows and dependencies between them become more complicated. In this paper I introduce asynchronous semantics and Promise type to Swift language (borrowing ideas from design of throw-try-catch and optionals). Functions can opt-in to become async, programmer can compose complex logic involving asynchronous operations while compiler produces necessary closures to implement that logic. This proposal does not propose new runtime model, nor "actors" or "coroutines".

Table of contents

@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra

@artem-sherbachuk
artem-sherbachuk / FadingInOutAVPlayer.swift
Created January 19, 2017 09:43
Fading audio in and out AVPlayer
let player = AVPlayer()
func playFileAtURL(url: NSURL) {
let asset = AVAsset.assetWithURL(url) as AVAsset
let duration = asset.duration
let durationInSeconds = CMTimeGetSeconds(duration)
let item = AVPlayerItem(asset: asset)
let params = AVMutableAudioMixInputParameters(track: asset.tracks.first! as AVAssetTrack)