Skip to content

Instantly share code, notes, and snippets.

@GottaGetSwifty
GottaGetSwifty / Proportional.storyboard
Created January 31, 2018 21:23
Proportional StackView
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
var myArray: [[String]] = [
["1", "picture1.png", "John", "Smith"],
["2", "picture2.png", "Mike", "Rutherford"],
]
func sort<T: Comparable>(ArrayOfArrays: [[T]], sortingIndex: Int, sortFunc: (T, T) -> Bool) -> [[T]] {
return ArrayOfArrays.sorted { sortFunc($0[sortingIndex], $1[sortingIndex])}
}
print(sort(ArrayOfArrays: myArray, sortingIndex: 0, sortFunc: <))
//[["1", "picture1.png", "John", "Smith"], ["2", "picture2.png", "Mike", "Rutherford"]]
@GottaGetSwifty
GottaGetSwifty / CollectionViewdidSelectItemAt.swift
Last active May 26, 2017 18:43
Example for CollectionView's didSelectItemAt with single selection
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
// First selection, just set it and reload that cell
guard let selectedIndexPath = selectedIndexPath else {
selectedIndexPath = indexPath
collectionView.reloadItems(at: [indexPath])
return
}
// Reset to none selected and reload that cell
if(selectedIndexPath == indexPath) {
selectedIndexPath = nil
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;