Hello:I am creating a Menu Bar Extra Item for my MAC os App. I have the following code but nothing displays on the menu bar. W ould appreciate some advice on where in the code I need to make changes:import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
//@IBOutlet weak var window: NSWindow!
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength)
// var item: NSStatusItem? = nil
@objc func QuitScorCentMasterReview(_ sender: Any?) {
NSApplication.shared.terminate(self)
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
if let button = statusItem.button {
button.image = NSImage(named:NSImage.Name("SMR_icon.png"))
button.action = #selector(QuitScorCentMasterReview(_:))
}
func constructMenu() {
let menu = NSMenu()
menu.addItem(NSMenuItem(title: "End the Application", action: #selector(NSApplication.terminate(_:)), keyEquivalent: ""))
statusItem.menu = menu
}
constructMenu()
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello:I have been struggling with this small piece of code foe days. Every time I resolve one problem with it, another one pops up:I seem to have resolved the problem of "Expected Pattern" but now I have the problem "Cannot call value of non-function type '[String]'Here is the code:var name = [String]() override func viewDidLoad() { super.viewDidLoad() let persistentContainer = NSPersistentContainer(name: "No_Regrets") persistentContainer.loadPersistentStores { (_, error) in if let error = error { fatalError("Failed to load Core Data stack: \(error)") } } // Creates a task with a new background context created on the fly persistentContainer.performBackgroundTask { (context) in //iterates the array let Gains = [self.gain1, self.gain2, self.gain3, self.gain4] Gains.forEach {_ in // Creates a new entry inside the context `context` and assign the array element `name` to the dog's name let gain1 = Gains(context: context) //Cannot call value of non-function type '[String]' gain1.name = name let gain2 = Gains(context: context) //Cannot call value of non-function type '[String]' gain2.name = name let gain3 = Gains(context: context) //Cannot call value of non-function type '[String]' gain3.name = name let gain4 = Gains(context: context) //Cannot call value of non-function type '[String]' gain4.name = name } do { // Saves the entries created in the `forEach` try context.save() } catch { fatalError("Failure to save context: \(error)") } }
Hello:
I am adding a video file to my MAC application. Before I create an archive, the video plays perfectly but when I run a copy of the archive, when I click on the button to start the video, NOTHING HAPPENS. No error message, Nothing. Any help to resolve this issue will be appreciated. Here is the code:
This code:
@IBAction func AVSegue(_ sender: Any) {
let mainStoryboard = NSStoryboard(name: "Main", bundle: Bundle.main)
guard let avPlayerViewController = mainStoryboard.instantiateController (withIdentifier: "AVID") as?
AVPlayerViewController else {
print("Couldn't find viewController" )
return
}
presentAsModalWindow(avPlayerViewController)
}
triggers the ViewController with the AV Player:
import Cocoa
import AVKit
import AVFoundation
class AVPlayerViewController: NSViewController {
@IBOutlet weak var playerView: AVPlayerView!
override func viewDidLoad() { super.viewDidLoad()
let url = URL(fileURLWithPath: Bundle.main.path(forResource:"SMRIntro",ofType: "mp4")!)
let player = AVPlayer(url: url)
playerView.player = player
player.play()
}
}
I successfully archived an app with Xcode 14.3.1. I air dropped it onto my iPhone 13. But when I tried to run the app by tapping the app icon the opening screen just flashes but does not allow to run the app. The same thing happens on my I pad. Any suggestions how to locate the reason for this behavior will be appreciated.
When I airdrop my archived app to my device it runs perfectly. But when I try to share with colleagues using the manifest.plist in a website link, the app will not install (Even on the same device where the airdropped app did). I get "Unable to Install [app name]"
Any help with this will be appreciated.
Here is my manifest.plist:
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://www.scorcent.com</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>url</key>
<string>https://www.scorcent.com/image_57x56.png</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>url</key>
<string>https://www.scorcent.com/image_512x512.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>ScorCent</string>
<key>bundle-version</key>
<string>6.0</string>
<key>kind</key>
<string>software</string>
<key>platform-identifier</key>
<string>com.apple.platform.iphoneos</string>
<key>title</key>
<string>NO REGRETS</string>
</dict>
</dict>
</array>
</dict>
</plist>
`And here is my web url;
<a href=itms-services://?action=download-manifest&url=https://www.scorcent.com/manifest.plist" Install App
Topic:
Developer Tools & Services
SubTopic:
Xcode