These are chat archives for devslopes/swiftios9

13th
Nov 2015
jjames1820
@jjames1820
Nov 13 2015 04:50
@spentak Ive only been able to get my classes to work in this fashion and not with the variables in the main class

import Foundation

class Math {

var result: Double = 0

func calculate(){

}

func getResult() ->String {
    return "The answer is \(result)"
}

}

class additon: Math {

var firstNumber: Double = 0
var secondNumber: Double = 0
var thirdNumber: Double = 0

init(firstNumber: Double, secondNumber: Double, thirdNumber: Double){
    self.firstNumber = firstNumber
    self.secondNumber = secondNumber
    self.thirdNumber = thirdNumber
}

override func calculate() {

    if thirdNumber == 0 {
        result = firstNumber + secondNumber
    }else{
        result = firstNumber + secondNumber + thirdNumber
    }
}

}

class subtraction: Math {

var firstNumber: Double = 0
var secondNumber: Double = 0
var thirdNumber: Double = 0

init(firstNumber: Double, secondNumber: Double, thirdNumber: Double) {
    self.firstNumber = firstNumber
    self.secondNumber = secondNumber
    self.thirdNumber = thirdNumber

}
override func calculate() {
    if thirdNumber == 0 {
        result = firstNumber - secondNumber
    }else{
        result = firstNumber - secondNumber - thirdNumber
    }
}

}

Mark Price
@spentak
Nov 13 2015 05:18

@jjames1820
```swift
class Math {
var firstNumber: Double
var secondNumber: Double
var result: Double!

init(first:Double, second:Double) {
    firstNumber = first
    secondNumber = second
}

func calculate() {

}

func getResult() -> String {

    if result == nil {
        return "Invalid result"
    } else {
        return "The answer is \(result)"
    }
}

}

class Addition: Math {
override func calculate() {
result = firstNumber + secondNumber
}
}

var add = Addition(first: 5, second: 6)
add.calculate()
add.getResult()

class Math {
    var firstNumber: Double
    var secondNumber: Double
    var result: Double!

    init(first:Double, second:Double) {
        firstNumber = first
        secondNumber = second
    }

    func calculate() {

    }

    func getResult() -> String {

        if result == nil {
            return "Invalid result"
        } else {
            return "The answer is \(result)"
        }
    }
}


class Addition: Math {
    override func calculate() {
        result = firstNumber + secondNumber
    }
}

var add = Addition(first: 5, second: 6)
add.calculate()
add.getResult()
try and analyze what I did
melisiweb
@melisiweb
Nov 13 2015 13:05
Hello everyone I am really new to Swift and I am having a problem I am sure you would solve in seconds. I was playing with NSTimer and for some unknown reason I am not able to stop the timer in my humble app. Could you help me?
import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var counterLbl: UILabel!


    @IBOutlet weak var startBtn: UIButton!

    @IBOutlet weak var pauseBtn: UIButton!


    @IBOutlet weak var stopBtn: UIButton!
    var counter = 0
    var timer : NSTimer!
    var isPaused: Bool = false

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    func increaseCounter() {
        counter++
        counterLbl.text = "\(counter)"
    }

    func startTimer() {
        timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "increaseCounter", userInfo: nil, repeats: true)
    }

    func pauseTimer() {
        timer.invalidate()
    }

    func stopTimer() {
        timer.invalidate()
        counter = 0
        counterLbl.text = "\(counter)"

    }

    @IBAction func onStartCounter(sender: AnyObject) {
        pauseBtn.hidden = false
        stopBtn.hidden = false
        startBtn.hidden = true
        startTimer()

    }

    @IBAction func onPauseCounter(sender: AnyObject) {
        if isPaused == true {
            isPaused = false
            startTimer()
        } else {
            isPaused = true
            pauseTimer()
        }
    }

    @IBAction func onStopCounter(sender: AnyObject) {
        stopTimer()
        startBtn.hidden = false
        pauseBtn.hidden = true
        stopBtn.hidden = true
    }
}
Tarek
@TarekSalama
Nov 13 2015 17:03
@spentak Is there a documentation (easy to comprehend one :D) that explains how an app’s cycle work? Like, when does viewDidLoad loads exactly, what other functions load before and after it and in what order, etc?
Tarek
@TarekSalama
Nov 13 2015 17:22

@spentak Thanks, that was simple :)

Just making sure I got it right. viewDidLoad gets called once per class. viewWillLoad and viewWillDisappear get called every time the class/view is loaded/unloaded. Correct?

Mark Price
@spentak
Nov 13 2015 17:30
Every time it visually appears to the user
melisiweb
@melisiweb
Nov 13 2015 19:14
Hi guys, does anybody know how to solve my problem above?
@melisiweb
melisiweb
@melisiweb
Nov 13 2015 19:26
thank you @spentak , I think It would be nice to know what does "on the same thread" means, do you know it by any chance? Thanks again
oh, looking at your picture I think I am following your course on udemy. Best video tutorial ever
JPROFFICIAL
@JPROFFICIAL
Nov 13 2015 19:42
@spentak how do I transfer information that I have previously hardcoded in from a main tableView controller, to a detail view. So when you click on a specific item on the list it shows specific information that I would set manually. All of the tutorials I have seen even on apple Developer have been adding an item to the list but I only want to present a detail view... I scanned the Pokedex app for how to do it but still seem in the dark.
Just like on twitter (or many other apps) you click on a list item and it shows you the details of the item on another VC.
Sketchy Swift
@HardcoreIOS
Nov 13 2015 19:45
@spentak I m getting a crash in the my favorite place app when I set a radius on the buttons
crash radius.png
I don’t have any bad connections either
Sketchy Swift
@HardcoreIOS
Nov 13 2015 19:54
Never mind, fixed it ;)
melisiweb
@melisiweb
Nov 13 2015 19:55
@HardcoreIOS do you know what "call a function on the same thread" means?
Sketchy Swift
@HardcoreIOS
Nov 13 2015 19:55
NO
melisiweb
@melisiweb
Nov 13 2015 19:55
ok thanks anyway :)
Sketchy Swift
@HardcoreIOS
Nov 13 2015 19:55
As far as I’m concerned, have no idea.
Tarek
@TarekSalama
Nov 13 2015 20:04
This is an interesting article i came across http://techcrunch.com/2015/11/11/no-ui-is-the-new-ui/?
Jack Davis
@jackd942
Nov 13 2015 20:41
In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system.
melisiweb
@melisiweb
Nov 13 2015 20:43
@jackd942 thank you but I was looking for something more related to my case. I can start a timer but I can't stop it :D
Jack Davis
@jackd942
Nov 13 2015 20:43
because it’s on a different thread, right?
Leon Wang
@leonw007
Nov 13 2015 20:43
is imageshack free? After the signup, it says I only have 30 days free trial?
melisiweb
@melisiweb
Nov 13 2015 20:43
I wrote the whole code above, it's super new stuff to me
Leon Wang
@leonw007
Nov 13 2015 20:59
is imageshack free? After the signup, it says I only have 30 days free trial? @spentak
Jack Davis
@jackd942
Nov 13 2015 20:59
In January 2014, ImageShack announced that it was switching to a subscription based service, and would no longer offer free uploads.
Leon Wang
@leonw007
Nov 13 2015 21:17
In their FAQ, they says
What can I do with my free account?
There are no expiry dates on free accounts. You will have access to the site including unlimited uploads, full privacy controls and no ads on account pages. Bandwidth limits may apply. Certain features are reserved for subscribed users and can be made available by upgrading your account at any moment you wish.
It's confusing, whether I can still upload the image when when free trail expired.
here is the link https://imageshack.us/faq
In the part of "What can I do with my free account?", it says you can still upload. However, in the section of "What happens to my account after the free trial expires?", it says you cannot upload images...
Jack Davis
@jackd942
Nov 13 2015 21:20
I never have used it…just going by a search...
I guess you can upload until your free trial expires…then just view
a lot of people on different forums recommend going to photobucket.com or imgur.com
Leon Wang
@leonw007
Nov 13 2015 21:23
And mark said it's free in the lecture 118, so I'm quite confused about this
Jack Davis
@jackd942
Nov 13 2015 21:23
that description is pretty confusing:)
IDK
jjames1820
@jjames1820
Nov 13 2015 21:34
@spentak Thanks for the insight!
Jack Davis
@jackd942
Nov 13 2015 21:36
Anybody else have this autolayout issue with Pokedex in landscape? Looks good in portrait, but I can’t seem to get landscape to cooperate. Happens in both the simulator as well as my personal iPhone 5s.
Screen Shot 2015-11-13 at 3.33.56 PM.png
I’ve removed constraints and tried a bunch of different stuff, but nothing seems to keep the background from moving up past the search bar and into the header view
Jack Davis
@jackd942
Nov 13 2015 21:53
Never mind…I changed the order around so that the background is behind the header view and then I changed the search bar tint and background to white and now it looks correct. Still not sure why the constraints aren’t working as expected, but I guess there are workarounds involved sometimes:)
Screen Shot 2015-11-13 at 3.51.00 PM.png
Sketchy Swift
@HardcoreIOS
Nov 13 2015 22:29
@jackd942 Nice app! :+1:
Jack Davis
@jackd942
Nov 13 2015 22:29
thanks…the autolayout issue was driving me crazy
Sketchy Swift
@HardcoreIOS
Nov 13 2015 23:53
I like blue better than red! @jackd942
Jack Davis
@jackd942
Nov 13 2015 23:54
That shade of blue has always been my favorite