Search results

  1. fukurou

    🐦swift swift grimoire

    round decimal to 2 decimal places : let temp = String(format: "%.2f", value)
  2. fukurou

    🐦swift swift grimoire

    mutating struct properties : struct Person { // define two properties var name = "" var age = 0 mutating func birthday(){ self.age += 1 } } // create instance of Person var person1 = Person() person1.birthday() print(person1.age)
  3. fukurou

    🐦swift Left side of mutating operator isn't mutable: 'self' is immutable

    struct Person { // define two properties var name = "" var age = 0 func birthday(){ age += 1 } } // create instance of Person var person1 = Person() birthday attempts to change the struct from within the struct so you need to add the prefix mutating : struct Person {...
  4. fukurou

    TNMT coming to Nintendo Switch on June 16, 2022

    yeah, I feel sorry for those who sold their nintendo switch 🍹 :kek:
  5. fukurou

    XCode grimoire

    MVC packaging R_click swift file->new group from selection->name the folder (model view or controler) set custom function parameter name : func greeter(msg message: String){ print(message) } greeter(msg: "hey") set custom func with no parameter name : func greeter(_ message...
  6. fukurou

    XCode grimoire

    setting view background color sender.backgroundColor = UIColor.green rest to clear : sender.backgroundColor = UIColor.clear
  7. fukurou

    XCode grimoire

    adding a swift file these files are where to store classes and structures file->new file (cmd + n)->swift file or right click the 1st dir in the project->new file
  8. fukurou

    🐦swift swift grimoire

    Struct vs. Class in Swift struct is pretty much a constant you can modify (with fields) 1 it gets passes as a value not as a reference 2 init is optional for struct 3 struct does have inheritance
  9. fukurou

    🐦swift swift grimoire

    struct // define a structure struct Person { // define two properties var name = "" var age = 0 } // create instance of Person var person1 = Person() // access properties and assign new values person1.age = 21 person1.name = "Rick" print("Name: \(person1.name) and Age: \( person1.age) ")
  10. fukurou

    🐦swift swift grimoire

    multi array 2d: var cinema = [[Int]]() or var cinema = Array(repeating: Array(repeating: 0, count: 5), count: 5) N-dimensional arrays var cinemas = [[[Int]]]() var cinemas = Array(repeating: Array(repeating: Array(repeating: 0, count: 5), count: 5), count: 3) cinemaRooms[1][2][3] = 1 // the...
  11. fukurou

    🐦swift swift grimoire

    Ternary Operator in Swift condition ? expression1 : expression2
  12. fukurou

    XCode grimoire

    defraculating a label set lines to 0 to have it add lines instead of trumping long strings and auto shrink to a minimum font size (15 in this example) the bigger the string the smaller the font will be
  13. fukurou

    XCode grimoire

    defraculating a progress bar set the height to > 1 to make it fatter than set the color and BG color with the tint property : :hmm: to see what a var type is select it and click option key
  14. fukurou

    XCode grimoire

    timer import UIKit class ViewController: UIViewController { let times: [String: Int] = ["soft":300, "medium":420,"hard":720] var secondsRamaining = 60 var timer = Timer() // declare the timer @IBAction func hardnessSelected(_ sender: UIButton) { secondsRamaining =...
  15. fukurou

    🐦swift swift grimoire

    switch with range switch x { case 80...90: print("x in range") case x..<10: print("x is small") case 50: print("50") default: print("Have you done something new?") } :hmm: ...10 can replace x..<10
  16. fukurou

    XCode grimoire

    link many buttons to one action drag click from the circle left to the code to the extra button while in assistant view (main->adjust editor options->assistant) import UIKit import AVFoundation class ViewController: UIViewController { var player: AVAudioPlayer! var tempSender...
  17. fukurou

    XCode grimoire

    re indent the code select the code->editor->structure->re-indent :hmm: in swift functions can have inner functions to see a functions scope choose a {} or move <> around the curly brackets
  18. fukurou

    XCode grimoire

    swift API Application Programming Interface https://developer.apple.com/documentation
Top