0

I am new to coding and especially swift. I would like to create an app in swift that will add the work week number to the menubar. For example, this week is work week 41, so on the menu bar it would say "WW41".

I know how to print text to the menubar, but just need to add the variable.

to get the work week I am doing this:

let calendar = Calendar.current
let weekOfYear = calendar.component(.weekOfYear, from: Date.init(timeIntervalSinceNow: 0))

To print just text, I am doing this:

        let statusBar = NSStatusBar.system
        statusBarItem = statusBar.statusItem(
            withLength: NSStatusItem.squareLength)
        statusBarItem.button?.title = "WW"

I'm just not sure how to write the actual work week number to the menubar. Also, I'm new to stackoverflow so thanks in advance.

  • 1
    It's hard to tell what you're really trying to do... do you want a menu bar item that's always there, no matter what app you're in? Or just a menu that's part of some app that you're writing? – Caleb Oct 11 '19 at 18:09
  • 1
    What is the question? – Willeke Oct 11 '19 at 19:43
  • Updated my question :) I want to put the work week number on the menubar app I am creating. – Warren McAllister Oct 11 '19 at 19:51
  • 1
    See [Convert Int to String in Swift](https://stackoverflow.com/questions/24161336/convert-int-to-string-in-swift) – Willeke Oct 11 '19 at 23:13

0 Answers0