Post

Replies

Boosts

Views

Activity

Reply to NSTreeController insertObject Failing
Effectively, video suggests that: first time, no selectionIndexPath : hence indexpath set at top second time, selection is first node, hence, indexpath set to 1 and after, insertObject fails, so it edits the current selection Could you test theIndexPath, just before calling [self insertObject:theTreeNode atArrangedObjectIndexPath:theIndexPath]; Could you also print the nodes count before and after insert ? Doc for insertObject says: Set the clearsFilterPredicateOnInsertion to YES to allow insertion. Could you try ? And to make sure you're on similar conditions, could you ask her to upgrade to 11.5.2 ?
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’21
Reply to How to stop an animation
You can do this (I added print to see what's happening: @IBAction func startAnimation(_ sender: NSButton) { NSAnimationContext.runAnimationGroup({ (context) in print("Start", view1.alphaValue) context.duration = 5.0 view1.animator().alphaValue = 0 print("End", view1.alphaValue) }) { // Completion print("Completed", self.view1.alphaValue) self.view1.alphaValue = 1.0 // You may need to reset at the end ? } } @IBAction func stopAnimation(_ sender: NSButton) { print("Stop") view1.layer?.removeAllAnimations() } When you stop, animation ends immediately and completion handler is called. Hope that helps.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to How to stop an animation
I want to click stop/pause and the animation stop at that point, at some % between 0 and 1 alphaValue I have not found a direct way to do it. But here is a workaround. At start of animation: get the alphaValue: initAlpha get the time In the completion, if elapsed is less than the set duration (here 5.0), which means animation was stopped: compute elapsedTime since beginning of animation compute what should be alpha at this time, if "normal" endValue (0) is endAlpha and normalDuration (5.0): let deltaAlpha = (initAlpha - endAlpha) * (elapsed / normalDuration) and set alpha inaccordingly: self.view1.alphaValue = initAlpha - deltaAlpha Full code should look like this: @IBAction func startAnimation(_ sender: NSButton) { let initAlpha = self.view1.alphaValue // Usually 1.0 let endAlpha = CGFloat(0) let startTime = DispatchTime.now() // Precisely when animation starts let fixedDuration = 5.0 var elapsedTime : Double = 0.0 NSAnimationContext.runAnimationGroup({ (context) in context.duration = fixedDuration // 5.0 self.view1.animator().alphaValue = endAlpha // 0 }) { // Completion let endTime = DispatchTime.now() elapsedTime = Double((endTime.uptimeNanoseconds - startTime.uptimeNanoseconds)) / 1_000_000_000 // Difference in seconds if elapsedTime >= fixedDuration { self.view1.alphaValue = initAlpha // return to initial value 1.0 } else { // Adjust proportionally let deltaAlpha = (initAlpha - endAlpha) * (elapsedTime / fixedDuration) self.view1.alphaValue = initAlpha - deltaAlpha } } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to IP packet class in Swift
Swift class for IP packets That's pretty vague spec ! V4 or V6 ? Do you just want to display or have other func in the class ? Here is for Python (I didn't look in details), maybe you can adapt: https://github.com/mike01/pypacker Full spec is in RFC791. have a look, really complex to cover all cases. https://datatracker.ietf.org/doc/html/rfc791
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to How to fix "appleaccountd quit unexpectedly" error?
It occurs also when leaving simulator or when leaving XCode, with simulator remaining open. Crash also occurs when working with playground, no use of simulator. Even without quitting XCode Launch XCode13ß4 (or XCode13ß5) Run app in simulator Stop app from XCode Quit Simulator Crash occurs a few seconds later. I filed a bug report : Aug 7, 2021 at 10:26 AM – FB9464093
Aug ’21
Reply to Barcode Scanner and write to Excel
You should read this old thread, which confirms what I told you: writing directly to an Excel file is overly complex. Not advised to try… https://developer.apple.com/forums/thread/23656 However, here is a parser https://github.com/CoreOffice/CoreXLSX or code to modify an empty file https://stackoverflow.com/questions/40403322/writing-data-from-tableview-to-excel-using-swift
Aug ’21
Reply to safe area - not understanding what I am seeing
I replicated your project: And ran it: What it shows: In storyboard, the tab bar item does appear in Navigation, but not in the views in navigation stack however, the TabBar appears there as well (in the 2 views of navigation stack) But when you run the app, the tabBarItems do appear in the view in navigation stack (the one with First In Nav label) It also appears in the next view in the navigation stack You can also see that there is a Back button in the secondView of navigation stack. Try to run your app: what do you get ? Just as you, what I do not understand is what is the gray area above the TabBar (just below label)? You probably did something wrong in your code, but just looking at your screenshots does not allow to guess what. Could you make a zip of the WHOLE project folder and attach as file ? Note: please use the right terminology: The storyboard to the lower right is to be connected to the Fermentation Calculator eventually via the navigation controller. It is not a storyboard here, it is a ViewController. Wrong terminology doesn't help understand each other.
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to Can you change the App Icons of other apps?
Changing the app icon requires changing the plist. Not possible programmatically. However; you can get a similar result manually with shortcuts: h t t p s : / / w w w .businessinsider.fr/us/how-to-change-app-icons-on-iphone I doubt you can do the same programmatically, because that would mean an app could create havoc in a user device… Not a problem if you do it for yourself, but pretty bad for others.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Fetch Core Data Issue
Could you explain in detail what you do and get and provide enough code so that we can understand: I can save it with a button Is it ?   @IBAction func save(_ sender: UIBarButtonItem) { If so, where do you save ? Where is context defined ? but I can not seem to retrieve the objects when I restart the app. Where do you try to reload ? I get it to print over 40000 (I have no idea why) What do you mean ? and I see no favourites in my favourites section when I added them before. Where are those favourites in the code above ?
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Fetch Core Data Issue
Really very hard, as each time, because you don't give a comprehensive view on your code. I get it to print over 40000 Could you explain ? Some unclear points in your code: How is CurrentPlayers defined ? Have you checked that data are effectively saved ? You should do a fetch just after save and test how many objects you get. Do you know which branch is executed in viewDidLoad ? Add some print: override func viewDidLoad() { super.viewDidLoad() if currentFav == nil { print("currentFav", currentFav) //display nil fetchSave() // <<<---- What do you get on console here ? self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none } else { print("currentFav", currentFav) NotificationCenter.default.post(name: .passFavNotification, object: self.currentFav) // <<<--- Who handles this notification ? How DispatchQueue.main.asyncAfter(deadline: .now() + 300) { self.reviewRating.requestReview(isWrittenReview: false) } } } You post a notification: please show how you handle it. Does fetch occur there ?
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to No email notification for answers to own posts
@Nickkk Just in case, here is where the bell is (but it doesn't work for me at this time).
Replies
Boosts
Views
Activity
Aug ’21
Reply to NSTreeController insertObject Failing
Effectively, video suggests that: first time, no selectionIndexPath : hence indexpath set at top second time, selection is first node, hence, indexpath set to 1 and after, insertObject fails, so it edits the current selection Could you test theIndexPath, just before calling [self insertObject:theTreeNode atArrangedObjectIndexPath:theIndexPath]; Could you also print the nodes count before and after insert ? Doc for insertObject says: Set the clearsFilterPredicateOnInsertion to YES to allow insertion. Could you try ? And to make sure you're on similar conditions, could you ask her to upgrade to 11.5.2 ?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to stop an animation
You can do this (I added print to see what's happening: @IBAction func startAnimation(_ sender: NSButton) { NSAnimationContext.runAnimationGroup({ (context) in print("Start", view1.alphaValue) context.duration = 5.0 view1.animator().alphaValue = 0 print("End", view1.alphaValue) }) { // Completion print("Completed", self.view1.alphaValue) self.view1.alphaValue = 1.0 // You may need to reset at the end ? } } @IBAction func stopAnimation(_ sender: NSButton) { print("Stop") view1.layer?.removeAllAnimations() } When you stop, animation ends immediately and completion handler is called. Hope that helps.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Cannot find 'SecondView' in scope in swiftui error NavigationView.
You have a semicolon here:                     Text; (("...")) Is it intentional ? That's not correct syntax. Double parenthesis are superfluous as well.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to stop an animation
I want to click stop/pause and the animation stop at that point, at some % between 0 and 1 alphaValue I have not found a direct way to do it. But here is a workaround. At start of animation: get the alphaValue: initAlpha get the time In the completion, if elapsed is less than the set duration (here 5.0), which means animation was stopped: compute elapsedTime since beginning of animation compute what should be alpha at this time, if "normal" endValue (0) is endAlpha and normalDuration (5.0): let deltaAlpha = (initAlpha - endAlpha) * (elapsed / normalDuration) and set alpha inaccordingly: self.view1.alphaValue = initAlpha - deltaAlpha Full code should look like this: @IBAction func startAnimation(_ sender: NSButton) { let initAlpha = self.view1.alphaValue // Usually 1.0 let endAlpha = CGFloat(0) let startTime = DispatchTime.now() // Precisely when animation starts let fixedDuration = 5.0 var elapsedTime : Double = 0.0 NSAnimationContext.runAnimationGroup({ (context) in context.duration = fixedDuration // 5.0 self.view1.animator().alphaValue = endAlpha // 0 }) { // Completion let endTime = DispatchTime.now() elapsedTime = Double((endTime.uptimeNanoseconds - startTime.uptimeNanoseconds)) / 1_000_000_000 // Difference in seconds if elapsedTime >= fixedDuration { self.view1.alphaValue = initAlpha // return to initial value 1.0 } else { // Adjust proportionally let deltaAlpha = (initAlpha - endAlpha) * (elapsedTime / fixedDuration) self.view1.alphaValue = initAlpha - deltaAlpha } } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to IP packet class in Swift
Swift class for IP packets That's pretty vague spec ! V4 or V6 ? Do you just want to display or have other func in the class ? Here is for Python (I didn't look in details), maybe you can adapt: https://github.com/mike01/pypacker Full spec is in RFC791. have a look, really complex to cover all cases. https://datatracker.ietf.org/doc/html/rfc791
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to fix "appleaccountd quit unexpectedly" error?
It occurs also when leaving simulator or when leaving XCode, with simulator remaining open. Crash also occurs when working with playground, no use of simulator. Even without quitting XCode Launch XCode13ß4 (or XCode13ß5) Run app in simulator Stop app from XCode Quit Simulator Crash occurs a few seconds later. I filed a bug report : Aug 7, 2021 at 10:26 AM – FB9464093
Replies
Boosts
Views
Activity
Aug ’21
Reply to iOS 15 beta6 crashes
Did you ask to the game developer ? They will be better inform than those who didn't develop the game (the developers here). May be they need to update their app…
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Barcode Scanner and write to Excel
You should read this old thread, which confirms what I told you: writing directly to an Excel file is overly complex. Not advised to try… https://developer.apple.com/forums/thread/23656 However, here is a parser https://github.com/CoreOffice/CoreXLSX or code to modify an empty file https://stackoverflow.com/questions/40403322/writing-data-from-tableview-to-excel-using-swift
Replies
Boosts
Views
Activity
Aug ’21
Reply to safe area - not understanding what I am seeing
I replicated your project: And ran it: What it shows: In storyboard, the tab bar item does appear in Navigation, but not in the views in navigation stack however, the TabBar appears there as well (in the 2 views of navigation stack) But when you run the app, the tabBarItems do appear in the view in navigation stack (the one with First In Nav label) It also appears in the next view in the navigation stack You can also see that there is a Back button in the secondView of navigation stack. Try to run your app: what do you get ? Just as you, what I do not understand is what is the gray area above the TabBar (just below label)? You probably did something wrong in your code, but just looking at your screenshots does not allow to guess what. Could you make a zip of the WHOLE project folder and attach as file ? Note: please use the right terminology: The storyboard to the lower right is to be connected to the Fermentation Calculator eventually via the navigation controller. It is not a storyboard here, it is a ViewController. Wrong terminology doesn't help understand each other.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Editor placeholder in source file
What happens if you just compile ? In many cases, if undue, the error clears.
Replies
Boosts
Views
Activity
Aug ’21
Reply to Can you change the App Icons of other apps?
Changing the app icon requires changing the plist. Not possible programmatically. However; you can get a similar result manually with shortcuts: h t t p s : / / w w w .businessinsider.fr/us/how-to-change-app-icons-on-iphone I doubt you can do the same programmatically, because that would mean an app could create havoc in a user device… Not a problem if you do it for yourself, but pretty bad for others.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Fetch Core Data Issue
Could you explain in detail what you do and get and provide enough code so that we can understand: I can save it with a button Is it ?   @IBAction func save(_ sender: UIBarButtonItem) { If so, where do you save ? Where is context defined ? but I can not seem to retrieve the objects when I restart the app. Where do you try to reload ? I get it to print over 40000 (I have no idea why) What do you mean ? and I see no favourites in my favourites section when I added them before. Where are those favourites in the code above ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to I have a problem with control center
Do you succeed in doing by using the smart function keys in the touch bar ?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Fetch Core Data Issue
Really very hard, as each time, because you don't give a comprehensive view on your code. I get it to print over 40000 Could you explain ? Some unclear points in your code: How is CurrentPlayers defined ? Have you checked that data are effectively saved ? You should do a fetch just after save and test how many objects you get. Do you know which branch is executed in viewDidLoad ? Add some print: override func viewDidLoad() { super.viewDidLoad() if currentFav == nil { print("currentFav", currentFav) //display nil fetchSave() // <<<---- What do you get on console here ? self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none } else { print("currentFav", currentFav) NotificationCenter.default.post(name: .passFavNotification, object: self.currentFav) // <<<--- Who handles this notification ? How DispatchQueue.main.asyncAfter(deadline: .now() + 300) { self.reviewRating.requestReview(isWrittenReview: false) } } } You post a notification: please show how you handle it. Does fetch occur there ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21