Skip to content

Instantly share code, notes, and snippets.

Avatar

Claudia Maciel-Contreras clc80

View GitHub Profile
View Cocoa Design Patterns
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 Jun 2, 2020
Make a function that takes two doubles return a string
View MakeChangeAsString.swift
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
Function to show bubble sort
View BubbleSort.Swift
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]
View ios-another-contains-swift-challenge.swift
extension String {
func anotherContains(sentence: String) -> Bool {
if self.lowercased().range(of: sentence.lowercased()) != nil {
return true
} else {
return false
}
}
}
View NotebooksLisltViewController.swift
//
// 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 Apr 21, 2020
Write a function that takes an Int and breaks it into its expanded form, returning each component in an array.
View expandTheNumber.swift
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 Mar 27, 2020
Detail Cocktail View Controller
View DetailCocktailViewController.swift
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 Mar 27, 2020
Cocktail Results Controller
View CocktailResultsController.swift
//
// CocktailResultController.swift
// cocktailMaker
//
// Created by Claudia Contreras on 3/25/20.
// Copyright © 2020 thecoderpilot. All rights reserved.
//
import Foundation
import UIKit
View CocktailResults.swift
//
// CocktailResults.swift
// cocktailMaker
//
// Created by Claudia Contreras on 3/25/20.
// Copyright © 2020 thecoderpilot. All rights reserved.
//
import Foundation
@clc80
clc80 / Palindrome.swift
Created Feb 11, 2020
Palindrome Swift Challenge
View Palindrome.swift
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
You can’t perform that action at this time.