In a viewController
usually there are many methods. In order make this part organized well. Here are the rules:
// MARK: - Life cycle
class CreateStudent < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :name | |
t.integer :age | |
end | |
end | |
end |
//: Playground - noun: a place where people can play | |
import UIKit | |
func swap<T>(inout value1: T, inout value2: T) { | |
let temporary = value1 | |
value1 = value2 | |
value2 = temporary | |
} |
/** | |
* Arrayadapter (for Android) with text filtering for the use with a TextWatcher. | |
* Note: the objects in the List need a valid toString() method. | |
* @author Tobias Schürg | |
* | |
*/ | |
public class FilteredArrayAdapter extends ArrayAdapter<ImageObject> { |
enum ChineseRange { | |
case notFound, contain, all | |
} | |
extension String { | |
var findChineseCharacters: ChineseRange { | |
guard let a = self.range(of: "\\p{Han}*\\p{Han}", options: .regularExpression) else { | |
return .notFound | |
} | |
var result: ChineseRange |
https://rink.hockeyapp.net/apps/aab3358c393742e2b1223c144755743a/app_versions/2166 |
#!/bin/sh | |
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal | |
# make sure the output directory exists | |
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" | |
# Step 1. Build Device and Simulator versions | |
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build | |
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build |
set -e | |
REVEAL_ARCHIVE_IN_FINDER=true | |
FRAMEWORK_NAME="${PROJECT_NAME}" | |
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework" | |
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework" | |
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal" |
extension Date { | |
func yearsCount(from date: Date) -> Int { | |
return Calendar.current.dateComponents([.year], from: date, to: self).year ?? 0 | |
} | |
func monthsCount(from date: Date) -> Int { | |
return Calendar.current.dateComponents([.month], from: date, to: self).month ?? 0 | |
} |
class GradientLineView: UIView { | |
override func draw(_ rect: CGRect) { | |
if let context = UIGraphicsGetCurrentContext() { | |
let startPoint1 = CGPoint(x: 20, y: rect.height/2) | |
let endPoint1 = CGPoint(x: rect.width-120, y: rect.height/2) | |
context.setLineWidth(15) | |
context.move(to: startPoint1) | |
context.addLine(to: endPoint1) | |
context.setLineCap(.round) |