Post

Replies

Boosts

Views

Activity

Reply to UITableView indexPath changing while scrolling
You are using meterNumber which is not defined in your shown code. Usually, having other variables than data source can easily cause issues as you describe. Also, you are setting textColor to .systemRed, but there is no code which changes textColor to the normal color, please do not forget that cells are reused, the textColor of the cell dequeued is not known. Anyway, to find how to fix, you may need to show more context.
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21
Reply to Swift generic usage inside class
What you are trying is not possible in the current type system of Swift. Better do the one way to solve even when you need to modify thousands of lines in your project. (Not exaggerating, assuming less than thousands.) Or else, if you could show very detailed info of the usage of EffectModel especially the property keyframeGroup, there might be other better workarounds. But anyway, you might have to modify EffectModel itself, under the current type system of Swift, no declaration using incomplete generic type like :[Keyframe<EffectParam>] is allowed.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to MPRemoteCommandCenter - Show Now Playing info
I have not played with MPNowPlayingInfoCenter, but you should better try doing it in the completion handler of the API call: override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. overrideUserInterfaceStyle = .light setupRemoteTransportControls() requestNowPlaying() //setupNowPlaying() addInterruptionsObserver() } //... DispatchQueue.main.async { self.songArtUrl = artUrl let albumArt = UIImage(data: imageData) self.artUrl.image = albumArt //Why don't you rename this, `artUrl` is not of type `URL`, very confusing... self.setupNowPlaying( artist: radio.nowPlaying.song.artist, title: radio.nowPlaying.song.title, artwork: albumArt) //<- } //... func setupNowPlaying(artist: String, title: String, artwork: UIImage?) { // Define Now Playing Info var nowPlayingInfo = [String : Any]() nowPlayingInfo[MPMediaItemPropertyTitle] = "\(artist) - \(title)" //<- nowPlayingInfo[MPMediaItemPropertyArtist] = "My name as string - nothing to change" if let image = artwork ?? UIImage(named: "Deault_albumart") { //<- nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { size in return image } } nowPlayingInfo[MPNowPlayingInfoPropertyIsLiveStream] = true MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo }
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to Can i Update my App with new project?
I recently published an app in the store. The app was created with a provider. Can I develope my own „new project“ and publish it as a 1.2 version? And terminate the provider. Or is that not possible? It depends on how the app is published on the App Store, if it is published with the Apple ID of the provider, the author of the app is the provider (from Apple's point of view). Unless the provider gives the ownership of the app in the way Apple defines to you, there's no way you can touch it. In case it is you who published the app using your own Apple ID, no problem. (Assuming you have not told the credentials of your Apple ID to anyone else.) Create an updated app with your own new project, better hold the same bundle ID, and submit it as the new version of your app.
Sep ’21
Reply to Open a View from the menu
You should better do it in the usual way of macOS programming. (You have no need to define your own nib, you have no need to define global variables.) Assuming you already added menu items Open view 1 and Open view 2 as in the screen shot, and the Custom Classes of the two view controllers are FirstViewController and SecondViewController. (The first may be ViewController, then you may need to replace FirstViewController to ViewController in the following code.) 1. Create a new file MyWindowController.swift and define the IBActions for Open view 1 and Open view 2 in it. MyWindowController.swift: import Cocoa class MyWindowController: NSWindowController { @IBAction func openView1(_ sender :Any) { guard let storyboard = self.storyboard else { return } let firstViewController = storyboard.instantiateController(withIdentifier: "FirstView") as? FirstViewController self.window?.contentViewController = firstViewController } @IBAction func openView2(_ sender :Any) { guard let storyboard = self.storyboard else { return } let secondViewController = storyboard.instantiateController(withIdentifier: "SecondView") as? SecondViewController self.window?.contentViewController = secondViewController } } 2. In the Interface Builder, change the Custom Class of your Window Controller to MyWindowController. 3. Connect the action of the menu item Open view 1 to openView1: of First Responder. (A pop up list is shown when you release the mouse button, you can choose openView1: from the list.) 4. Connect the action of the menu item Open view 2 to openView2: of First Responder as well. 5. Run your code. If you find something wrong, please tell me. I did test.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to Swift Playgrounds in iOS15
the new interface announced at WWDC21 I may be mistaking what you mean by the new interface, but the latest iPadOS 15 page says that the new SwiftPlaygrounds is Available late 2021. (Please check another answer of mine.) You may need to wait a little more.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to What exactly is CIImage extent
The doc of extent says: This rectangle specifies the extent of the image in working space coordinates. In other words, it is a rectangular region which the processed image is expected to occupy in the same coordinate as in the original image. Don't you think it is quite reasonable you get negative values when you applied rotation on the image?
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21
Reply to UITableView refresh issue
Please show enough code. You are hiding the most suspicious parts with this block of code works properly. How have you checked if it works properly?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to xcode is so weak,a non-ascii character can cause a crash without any clear infomation
The title is not clear enough. Can you explain where you put that non-ascii character? And better clarify the version of the Xcode and your Mac.
Replies
Boosts
Views
Activity
Sep ’21
Reply to UITableView indexPath changing while scrolling
You are using meterNumber which is not defined in your shown code. Usually, having other variables than data source can easily cause issues as you describe. Also, you are setting textColor to .systemRed, but there is no code which changes textColor to the normal color, please do not forget that cells are reused, the textColor of the cell dequeued is not known. Anyway, to find how to fix, you may need to show more context.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Swift generic usage inside class
What you are trying is not possible in the current type system of Swift. Better do the one way to solve even when you need to modify thousands of lines in your project. (Not exaggerating, assuming less than thousands.) Or else, if you could show very detailed info of the usage of EffectModel especially the property keyframeGroup, there might be other better workarounds. But anyway, you might have to modify EffectModel itself, under the current type system of Swift, no declaration using incomplete generic type like :[Keyframe<EffectParam>] is allowed.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to MPRemoteCommandCenter - Show Now Playing info
I have not played with MPNowPlayingInfoCenter, but you should better try doing it in the completion handler of the API call: override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. overrideUserInterfaceStyle = .light setupRemoteTransportControls() requestNowPlaying() //setupNowPlaying() addInterruptionsObserver() } //... DispatchQueue.main.async { self.songArtUrl = artUrl let albumArt = UIImage(data: imageData) self.artUrl.image = albumArt //Why don't you rename this, `artUrl` is not of type `URL`, very confusing... self.setupNowPlaying( artist: radio.nowPlaying.song.artist, title: radio.nowPlaying.song.title, artwork: albumArt) //<- } //... func setupNowPlaying(artist: String, title: String, artwork: UIImage?) { // Define Now Playing Info var nowPlayingInfo = [String : Any]() nowPlayingInfo[MPMediaItemPropertyTitle] = "\(artist) - \(title)" //<- nowPlayingInfo[MPMediaItemPropertyArtist] = "My name as string - nothing to change" if let image = artwork ?? UIImage(named: "Deault_albumart") { //<- nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { size in return image } } nowPlayingInfo[MPNowPlayingInfoPropertyIsLiveStream] = true MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How do you refresh the string displayed by a NSTextField?
I'm looking for a more elegant solution. Can you clarify what you think is more elegant? What I can think of first is setNeedsDisplay:YES and it is quite elegant for me.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Can i Update my App with new project?
I recently published an app in the store. The app was created with a provider. Can I develope my own „new project“ and publish it as a 1.2 version? And terminate the provider. Or is that not possible? It depends on how the app is published on the App Store, if it is published with the Apple ID of the provider, the author of the app is the provider (from Apple's point of view). Unless the provider gives the ownership of the app in the way Apple defines to you, there's no way you can touch it. In case it is you who published the app using your own Apple ID, no problem. (Assuming you have not told the credentials of your Apple ID to anyone else.) Create an updated app with your own new project, better hold the same bundle ID, and submit it as the new version of your app.
Replies
Boosts
Views
Activity
Sep ’21
Reply to Are Button actions on the MainActor?
Better fix the passed-in closure, Adding @MainActor may not be the right solution (even when Xcode suggested that).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to SwiftUI iOS 15: Nested navigation link isActive not observing change
I could have reproduced the issue you described. Whether it is a known issue or not, you should better send a bug report. Many apps made of SwiftUI may depend on this behavior.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Open a View from the menu
You should better do it in the usual way of macOS programming. (You have no need to define your own nib, you have no need to define global variables.) Assuming you already added menu items Open view 1 and Open view 2 as in the screen shot, and the Custom Classes of the two view controllers are FirstViewController and SecondViewController. (The first may be ViewController, then you may need to replace FirstViewController to ViewController in the following code.) 1. Create a new file MyWindowController.swift and define the IBActions for Open view 1 and Open view 2 in it. MyWindowController.swift: import Cocoa class MyWindowController: NSWindowController { @IBAction func openView1(_ sender :Any) { guard let storyboard = self.storyboard else { return } let firstViewController = storyboard.instantiateController(withIdentifier: "FirstView") as? FirstViewController self.window?.contentViewController = firstViewController } @IBAction func openView2(_ sender :Any) { guard let storyboard = self.storyboard else { return } let secondViewController = storyboard.instantiateController(withIdentifier: "SecondView") as? SecondViewController self.window?.contentViewController = secondViewController } } 2. In the Interface Builder, change the Custom Class of your Window Controller to MyWindowController. 3. Connect the action of the menu item Open view 1 to openView1: of First Responder. (A pop up list is shown when you release the mouse button, you can choose openView1: from the list.) 4. Connect the action of the menu item Open view 2 to openView2: of First Responder as well. 5. Run your code. If you find something wrong, please tell me. I did test.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to What happened to primaryAction in Menu?
As I wrote, the released version of Xcode 13 (13A233) does not contain macOS SDK 12. You can find older betas on More Downloads pages.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to What happened to primaryAction in Menu?
Can you clarify the exact version of your Xcode? If you are using the released version of Xcode 13, it does not contain macOS SDK 12, so you cannot use Menu(content:label:primaryAction:) as shown in the doc of the initializer.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Returning different dates from CoreData objects using NSPredicate
it should return 2 You may be mistaking. The type Date contains sub-second info in it. The first Date() and the second may return different values. Generally NSPredicate is not a tool for counting, and working with actual date (year-month-day) with the type Date would be complex.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Swift Playgrounds in iOS15
the new interface announced at WWDC21 I may be mistaking what you mean by the new interface, but the latest iPadOS 15 page says that the new SwiftPlaygrounds is Available late 2021. (Please check another answer of mine.) You may need to wait a little more.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to What exactly is CIImage extent
The doc of extent says: This rectangle specifies the extent of the image in working space coordinates. In other words, it is a rectangular region which the processed image is expected to occupy in the same coordinate as in the original image. Don't you think it is quite reasonable you get negative values when you applied rotation on the image?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21