Post

Replies

Boosts

Views

Activity

Develop an application for MacOS for educational purposes
Hello everyone. I'm slowly learning Swift and programming on MacOS (the one for IOS will come maybe later). I would like to develop something, but I need a goal to achieve, because nothing comes to mind on two feet. Could you recommend something not too complicated to develop that is not present on MacOS or is no longer updated? Of course I don't do it for money, I also publish the source without problems here, for the moment I would only like to have some goal to achieve while I learn. Thanks so much!
1
0
317
Jul ’20
Why my timer won't go?
I am a total noob and I'm learning.I have a question: why I get an error after my application start?This is the code for the timer:Import UIKit var counter = 0 class ViewController: UIViewController { @IBOutlet weak var Label1: UILabel @IBOutlet weak var Switch1: UISwitch! var timer1 = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerAction), userInfo: nil , repeats: true) @objc func timerAction() { counter = counter + 1 Label1.text = String(counter) } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } }Thanks a lot in advance!
3
0
569
Apr ’20
Please, someone could help me to convert a function from Python to Swift 4?
Hello I have to port a very simple application from Python to Swift, but I can't understand how to convert that function:def crc16(data, bits=8): crc = 0xFFFF for op, code in zip(data[0::2], data[1::2]): crc = crc ^ int(op+code, 16) for bit in range(0, bits): if (crc&0x0001) == 0x0001: crc = ((crc >> 1) ^ 0xA001) else: crc = crc >> 1 msb = crc >> 8 lsb = crc & 0x00FF return '{:X}{:X}'.format(lsb, msb)And the result is shown by that code:print crc16('11010003000C')The code have to calculate the CRC16 of a string.For example, for the string:11 01 00 03 00 0CThe CRC calculated must beCE9F (CE High, 9F Low)And for the string11 01 02 CD 0BThe result of the CRC must be6D 68I'm trying to make some steps, but I am far away from the results....There is a way to write it in swift?
8
0
2.7k
Nov ’17