Skip to content

Instantly share code, notes, and snippets.

View yunustek's full-sized avatar
🏠
Working from home

Yunus Tek yunustek

🏠
Working from home
View GitHub Profile
@yunustek
yunustek / iOS.8.3.txt
Created March 12, 2018 14:19
iOS UIFont names
UIFont: family Thonburi
UIFont: font Thonburi-Bold
UIFont: font Thonburi
UIFont: font Thonburi-Light
UIFont: family Khmer Sangam MN
UIFont: font KhmerSangamMN
UIFont: family Snell Roundhand
UIFont: font SnellRoundhand-Black
UIFont: font SnellRoundhand-Bold
UIFont: font SnellRoundhand
@yunustek
yunustek / NewViewController.swift
Last active October 7, 2018 16:49
Derived Collection of Enum Cases
enum Cities: CaseIterable {
static var allCases: [Cities] {
return [.antwerp, .brussels, .mumbai, .hyderabad(countryName: "India")]
}
case antwerp
case brussels
case mumbai
case hyderabad(countryName: String)
}
@yunustek
yunustek / OldViewController.swift
Created October 7, 2018 16:50
Derived Collection of Enum Cases:
enum CompassDirection: CaseIterable {
case north, south, east, west
}
print("There are \(CompassDirection.allCases.count) directions.")
// Prints "There are 4 directions."
let caseList = CompassDirection.allCases
.map({ "\($0)" })
.joined(separator: ", ")
// caseList == "north, south, east, west"
@yunustek
yunustek / OldViewController.swift
Created October 7, 2018 16:52
Yeni Derleyici Yönergeleri
func encrypt(_ string: String, with password: String) -> String {
#warning("This is terrible method of encryption")
return password + String(string.reversed()) + password
}
struct Configuration {
var apiKey: String {
#error("Please enter your API key below then delete this")
return "Enter your key here"
}
}
@yunustek
yunustek / ViewController.swift
Created October 7, 2018 16:54
Yeni Derleyici Yönergeleri
#if false
#warning("this will not trigger a warning")
#error("this will not trigger an error")
#endif
#if true
#warning("this will trigger a warning")
#error("this will trigger an error")
#endif
@yunustek
yunustek / ViewController.swift
Created October 7, 2018 16:55
Random Sayı Üretimi
//generate a random number in the range 1 through 100
let randomInt = Int.random(in: 1..<100)
let randomFloat = Float.random(in: 1..<100)
let randomDouble = Double.random(in: 1…100)
let randomCGFloat = CGFloat.random(in: 1…100)
//generate a random bool
let randomBoolean = Bool.random()
@yunustek
yunustek / ViewController.swift
Created October 7, 2018 16:56
Random Sayı Üretimi
var groceryList = ["Milk", "Eggs", "Bread", "Nutella"]
if let randomGroceryItem = groceryList.randomElement() {
print("The random grocery item is \(randomGroceryItem)")
}
//The random grocery item is Milk
var names = ["Alejandro", "Camila", "Diego", "Luciana", "Luis", "Sofía"]
names.shuffle()
//names == ["Luis", "Camila", "Luciana", "Sofía", "Alejandro", "Diego"]
let numbers = 0…9
let shuffledNumbers = numbers.shuffled()
// shuffledNumbers == [1, 7, 6, 2, 8, 9, 4, 3, 5, 0]
@yunustek
yunustek / ViewController.swift
Created October 7, 2018 16:57
Testing Sequence Elements
let names = ["Sofia", "Camilla", "Martina", "Mateo", "Nicolás"]
let allHaveAtLeastFive = names.allSatisfy({ $0.count >= 5 })
// allHaveAtLeastFive == true
@yunustek
yunustek / ViewController.swift
Created October 7, 2018 16:57
Removing Elements from Collection
var numbers = [5, 6, 7, 8, 9, 10, 11]
numbers.removeAll(where: { $0 % 2 == 1 })
// numbers == [6, 8, 10]