Writing the code like the below seems to resolve the CPU and wrong calculation issues at first impression. I need to do extensive tests to see if the calculations are really correct.
Thank you Claude31 for your help about the [self] clause.
var editmenuItems : [UIAction] {
return [
UIAction(title: "Edit Value", image: UIImage(systemName: "square.and.pencil"), handler: { [weak self]
(_) in
self?.edit()
}),
UIAction(title: "Fill Values", image: UIImage(systemName: "ellipsis.rectangle"), handler: { [weak self]
(_) in
self?.fill()
})
]
}
var editMenu: UIMenu {
return UIMenu(children: editmenuItems)
}
editButton.menu = editMenu
Post
Replies
Boosts
Views
Activity
Claude31,
I included the [self] and it did not solve the problem.
In fact if the handler code does not include any class variables then the code works without CPU problems.
For example, if vGlobal is a global variable and vLocal is a local variable
import Foundation
import UIKit
var vGlobal = 0
class ViewController: UIViewController {
var vLocal = 0
.
.
override func viewDidLoad {
super.viewDidLoad()
.
.
UIAction(title: "Edit Value", image: UIImage(systemName: "square.and.pencil"), handler: {
(_) in
print(self.vLocal) // problem
print(vGlobal) // no problem
})
.
.
}
.
.
}
Claude31, the class is long.
However the root controller has similar code and the menus do not cause any problem on the root view controller.
There are also other view controllers that are pushed from root view controller and bar button menu(s) causes the same CPU and wrong calculation problems there too.
It seems related with the push (segue) from the root view controller to other view controllers.
With each back to root and push to other view controller CPU load and wrong calculation amount increase.
I both tried putting the bar button through storyboard and programmatically, but it did not matter in either case.
Putting statements instead of function call does not cause CPU or wrong calculation problems.
But it is not practical since some of my functions are long.
var editmenuItems : [UIAction] {
return [
UIAction(title: "Edit Value", image: UIImage(systemName: "square.and.pencil"), handler: {
(_) in
// self.test() // function call causes problems
print("test" // no problem
}),
UIAction(title: "Fill Values", image: UIImage(systemName: "ellipsis.rectangle"), handler: {
(_) in
// self.test() // function causes problems
print("test" // not problem
})
]
}
where
func test() {
print("test")
}
var editmenuItems : [UIAction] {
return [
UIAction(title: "Edit Value", image: UIImage(systemName: "square.and.pencil"), handler: {
(_) in
// self.edit()
self.test()
}),
UIAction(title: "Fill Values", image: UIImage(systemName: "ellipsis.rectangle"), handler: {
(_) in
// self.fill()
self.test()
})
]
}
and
func test() {
print("Test")
}
self is required by the compiler.
Ok. I tried your suggestion.
Still the CPU and wrong calculation problems continue.
Complete viewDidLoad does not have any other lines related to this.
But, if I comment out self.edit()and self.fill() and uncomment editButton.menu = editMenu,
then the CPU and wrong calculation problems go away too.
Claude31,
Thanks. But it does not help either.
I installed my app through TestFlight. At first it again displayed only in USD. But when I tried the restore option of my app, and after entering Apple ID credentials (although the version in App Store does not ask for credentials if I have already signed in through settings) it displayed the correct currency. Interesting is that after uninstalling both the TestFlight version and the TestFlight app itself, running the app through Xcode 12 also displayed the correct currency.
Somehow the problem seems solved in my case.
Unfortunately, Xcode GM Seed Version 12.1 (12A7403) does not solve the problem either.
FB8751659
This my feedback I’d.
Xcode 12.0.1 has not fixed the issue too.
At the moment it is not possible for me to load a new version to the App Store.
Let’s hope it gets fixed soon.
I experience the same for my app. Regardless of the region selected, if I install my app using Xcode 12 on a iOS 14 phone the price is fetched as USD price only.
I tried Xcode 12.2 beta and the problem continues.
However there is no problem with iOS 13 or previous iPhone.
My same app currently on App Store loaded with Xcode 11 both shows correct price in iOS 14 and iOS 13 or previous versions.
Tried all the suggestions from Apple Staff but the problem is not solved.