Skip to content

Instantly share code, notes, and snippets.

View 0xLeif's full-sized avatar
🇺🇦
Updating projects to Swift 6

Zach 0xLeif

🇺🇦
Updating projects to Swift 6
View GitHub Profile

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@flandy84
flandy84 / gist:3183844
Created July 26, 2012 19:05
"modern Objective-C" syntax
//"modern Objective-C" syntax
//new enum-macros for better autocompletion, switch statement, more precise warnings, ...
typedef NS_ENUM(NSInteger, MyViewContentMode) {
MyViewContentModeLeft,
MyViewContentModeRight,
MyViewContentModeTopLeft,
MyViewContentModeTopRight,
@mischah
mischah / z.md
Last active December 9, 2022 02:11
Installing und initializing z (https://github.com/rupa/z) with help of Homebrew.

#The power of z

Do you spend lots of time doing things like this?

cd this/is/the/path/that/i/want/so/i/type/it/all/out/to/get/whereiwant

With z, you could just do this:

@lattner
lattner / TaskConcurrencyManifesto.md
Last active November 15, 2024 05:45
Swift Concurrency Manifesto
@cprovatas
cprovatas / BlockBasedSelector.h
Last active June 9, 2024 13:08
Block-Based Selectors in Swift
//
// BlockBasedSelector.h
//
// Created by Charlton Provatas on 11/2/17.
// Copyright © 2017 CharltonProvatas. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BlockBasedSelector : NSObject
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active November 15, 2024 01:56
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@0xLeif
0xLeif / KP.swift
Last active August 21, 2020 22:21
KeyPath
import UIKit
precedencegroup KeyPathPrecedence {
associativity: right
higherThan: MultiplicationPrecedence
}
infix operator ...: KeyPathPrecedence
@IanColdwater
IanColdwater / twittermute.txt
Last active November 17, 2024 02:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@0xLeif
0xLeif / BrandedLoadingView.swift
Created February 18, 2020 16:11
SwiftUIKit Custom Loading View
class BrandedLoadingView: UIView {
fileprivate var spinnerView = View()
fileprivate var topLeftSpinnerView = View()
.layer { $0.addSublayer(dotLayer()) }
fileprivate var bottomRightSpinnerView = View()
.configure {
$0.transform = $0.transform.rotated(by: .pi)
}
.layer { $0.addSublayer(dotLayer()) }