Skip to content

Instantly share code, notes, and snippets.

View clc80's full-sized avatar

Claudia Maciel clc80

View GitHub Profile
Objective challenge:
Q1) Pair off, and with a peer, each choose a design pattern and think of an instance you’ve used it code you’ve written or have seen it used in UIKit.
A1) We have used the MVC pattern in our beginning projects. We used this design pattern in our first build week project.
Objective challenge:
Q2)Look through the documentation and find at least one UIKit class that uses the singleton pattern.
A2) App Delegate
Objective challenge:
Q3) Think about a time we’ve used the facade pattern before. Are there places that we could have used it to write better code but didn’t? Discuss with a peer.
@clc80
clc80 / MakeChangeAsString.swift
Created June 2, 2020 02:53
Make a function that takes two doubles return a string
import UIKit
func makeChangeAsString(fromAmount: Double, withCost: Double) -> String {
let change = fromAmount - withCost
let dollars = Int(change / 1)
var cents = change.truncatingRemainder(dividingBy: 1)
let quarters = Int(cents / 0.25)
cents -= Double(quarters) * 0.25
let dimes = Int(cents / 0.10)
@clc80
clc80 / BubbleSort.Swift
Created May 19, 2020 02:44
Function to show bubble sort
import UIKit
func bubbleSort<AnyItem: Comparable>(_ array: [AnyItem] ) -> [AnyItem] {
var newArray = array
var temp: AnyItem
for i in 0..<newArray.count - 1 {
for j in (i + 1)..<newArray.count {
if newArray[i] > newArray[j] {
//swap
temp = newArray[i]
extension String {
func anotherContains(sentence: String) -> Bool {
if self.lowercased().range(of: sentence.lowercased()) != nil {
return true
} else {
return false
}
}
}
//
// NotebooksListViewController.swift
// Mooskine
//
// Created by Josh Svatek on 2017-05-31.
// Copyright © 2017 Udacity. All rights reserved.
//
import UIKit
import CoreData
@clc80
clc80 / expandTheNumber.swift
Created April 21, 2020 02:27
Write a function that takes an Int and breaks it into its expanded form, returning each component in an array.
func expandTheNumber(_ number: Int) -> [Int] {
var copyOfNum = number
var zeroPlaces = 1
var newArray: [Int] = []
if number < 10 {
newArray.append(number)
} else {
while copyOfNum >= 1 {
newArray.insert(((copyOfNum % 10) * zeroPlaces), at: 0)
@clc80
clc80 / DetailCocktailViewController.swift
Last active March 27, 2020 23:45
Detail Cocktail View Controller
import UIKit
class DetailCocktailViewController: UIViewController {
// MARK: - IBOutlets
@IBOutlet var drinkNameLabel: UILabel!
@IBOutlet var imageView: UIImageView!
@IBOutlet var IngredientsTextView: UITextView!
@IBOutlet var instructionsTextView: UITextView!
@clc80
clc80 / CocktailResultsController.swift
Last active March 27, 2020 00:11
Cocktail Results Controller
//
// CocktailResultController.swift
// cocktailMaker
//
// Created by Claudia Contreras on 3/25/20.
// Copyright © 2020 thecoderpilot. All rights reserved.
//
import Foundation
import UIKit
//
// CocktailResults.swift
// cocktailMaker
//
// Created by Claudia Contreras on 3/25/20.
// Copyright © 2020 thecoderpilot. All rights reserved.
//
import Foundation
@clc80
clc80 / Palindrome.swift
Created February 11, 2020 03:15
Palindrome Swift Challenge
import UIKit
func canBePalindrome(string: String) -> Bool {
//lowercase the string
string.lowercased()
//Reverse it in a new string
let newString = String(string.reversed())
//compare the values