Skip to content

Instantly share code, notes, and snippets.

@emotality
emotality / duplicate_line_xcode.md
Last active April 6, 2024 04:23
Xcode - Duplicate Line key binding

NOTE (2022-07-09): Xcode finally added this functionality in Xcode 14, please see release notes here:

New Features in Xcode 14 Beta 3
When editing code, the Edit > Duplicate menu item and its corresponding keyboard shortcut now duplicate the selected text — or the line that currently contains the insertion point, if no text is selected. (8614499) (FB5618491)


Xcode line duplicate

Bind keys to duplicate lines in Xcode

@yannickl
yannickl / YLColor.swift
Last active September 16, 2023 03:55
Hex string <=> UIColor conversion in Swift
import Foundation
import UIKit
extension UIColor {
convenience init(hexString:String) {
let hexString:NSString = hexString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let scanner = NSScanner(string: hexString)
if (hexString.hasPrefix("#")) {
scanner.scanLocation = 1
@iOSDigital
iOSDigital / gist:8379249
Created January 12, 2014 01:14
UIImage doesn't have a tint colour. UIImageView does. This little method returns a UIImage, tinted with a UIColor. It's useful for things like table icons, where the image view is read only. Means you don't have to create loads of PNGs in different colours.
-(UIImage *)imageWithTint:(UIImage *)image andTintColor:(UIColor *)tintColor {
UIImage *imageNew = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:imageNew];
imageView.tintColor = tintColor;
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 0.0);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@iggym
iggym / Xcode-Gitignore-files.txt
Last active February 26, 2022 23:40
Xcode Gitignore files
Below are multiple .gitignore files for use with Xcode/Objective-C projects
##########################################
# OS X
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
@johngraham262
johngraham262 / openx_bash_for_ios
Last active December 9, 2022 02:34
A simple bash script that will open a `.xcworkspace` if it exists in the current directory, otherwise a `.xcodeproj` if it exists, otherwise nothing. It will print the name of the file that is being opened. When using Cocoapods with iOS apps, a second file is created with the `MyProject.xcworkspace` name, alongside the `MyProject.xcproject` file…
# Add the following lines of code to your `~/.bash_profile`,
# and then run `source ~/.bash_profile` to be able to execute
# this from the command line.
openx() {
fileToOpen='';
for file in `find . -maxdepth 1 -name *.xcworkspace`; do
fileToOpen=$file
done
Don't worry about what anybody else is going to do. The best way to
predict the future is to invent it.
-- Alan Kay
Premature optimization is the root of all evil (or at least most of it)
in programming.
-- Donald Knuth
Lisp has jokingly been called "the most intelligent way to misuse a
computer". I think that description is a great compliment because it