Post

Replies

Boosts

Views

Activity

Reply to When observing a notification that may be posted "on a thread other than the one used to registered the observer," how should I ensure thread-safe UI work?
Should I dispatch to the main queue from within my presentAlert function, or... That's one thing required. But if your issue is really caused by threading problem, there may be many other things to fix. Better try fixing it and test on the TestFlight with as many testers involved as you can.
Topic: App & System Services SubTopic: General Tags:
Oct ’21
Reply to Text Field doesn't update
Is there a way to show the app launch screen until firebase fully loads, NO. maybe there is any other way? Many apps show sort of Loading View while some sort of communication is going on. Simply, you can show a better word than "nil", or you could show your own Loading View (other than launch screen).
Topic: App & System Services SubTopic: General Tags:
Oct ’21
Reply to App crashes at WKWebView's 'load' method
Can you show the whole message shown in the debug console? I have not tested enough, but recent iOS are eager to detect more unexpected usages than ever. Do you think of anything unusual in the usage of your WKWebView? Showing more context, including the content of stringUrl or other project settings related to WKWebView may help.
Oct ’21
Reply to ShazamKit API URL
Does anyone know if there is an official URL for the Shazam API and how I can use it? As far as I know, Apple has never announced the Web API for ShazamKit. And the current shazam.com (Shazam is now a family company of Apple) does not have any documentations or links to the API you have shown. So, you may need to research and learn it by yourself and use it on your own risk. (Seems it is not free.)
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21
Reply to NavigationLink destination - Set view programmatically
As far as I read your requirements, you do not seem to have many choices. One possible way, prepare a generic TaskView: struct TaskView: View { let number: Int var body: some View { switch number { case 1: Task01View() case 2: Task02View() case 3: Task03View() //... default: EmptyView() } } } And use it like this: ForEach(0...6, id: \.self) { task in NavigationLink( destination: TaskView(number: task) ) { Text("\(task). Aufgabe") .font(.custom("Chalkduster", fixedSize: 16)) .foregroundColor(Color(UIColor.brown)) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to How to make good User Interfaces
@MinhQuang I cannot say what are good User Interfaces, but it seems you have your own good User Interfaces in mind. Please try to explain what is the problem of the current UI and what would be your expected UI. I do not understand what you mean by I can't make the inside park I tried to use List layout but it didn't work out. Hand-drawn sketch would help. Please do not forget to show your current code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Accessing an environmentObject's function in another environmentObject which is created at the same time
The problem is, that is dont only need the billModel in the PDFManger but also everywhere else in the App I do not think that would be an issue, you can do what Dirk-FU said: class PDFManager: ObservableObject { var billModel : BillModel? func saveToDB() { billModel?.addData(billToAdd: bill) } //... } And set PDFManager.billModel on start up of your app: var body: some Scene { WindowGroup { MainView() .environmentObject(billModel) .environmentObject(customerModel) .environmentObject(itemModel) .environmentObject(sheet) .environmentObject(manager) .onAppear(perform: { manager.billModel = billModel billModel.getData() customerModel.getData() itemModel.getData() }) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Imported Image Orientation
If you come here to solve your issue, please try to explain your problem precisely. Please show your code to reproduce the issue, what is the current behavior and what would be the expected behavior. Including screen shots and images would help readers understanding.
Topic: Media Technologies SubTopic: General Tags:
Oct ’21
Reply to Should a delegate property passed into a struct also be declared as weak in the struct?
Should the delegate property in the struct also be marked with weak? It depends on whether it may create a reference cycle or not. In the example code you have shown, hostingController may hold a strong reference to ExampleView.delegate, but it is not held as a strong reference in viewController. (Please start type names with Capital letter, even in a simplified example.) So, you have no need to declare the property ExampleView.delegate as weak. Generally, in case of View structs, you have no need to care about reference cycles if you are using the View in a usual way. But, if you are not using the View in a usual way, or the struct is not a View and it may be used in various ways, you may need to place weak on properties which may make reference cycle. If you do not understand what would be usual nor what might make reference cycles, better use weak even when it is not named delegate.
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’21
Reply to How Do You Assign Int To UILabel
When you show your code, please show it as text using Code Block. With showing easily testable code, more readers would try to solve your issue. And in Swift, only type names start with Capital letter. Score or ScoreButton are not Swifty names. And one more, if TestViewController is actually a subclass of ViewController, it might not be appropriate to instantiate it like TestViewController(). This may cause many critical issues. We need to guess some parts of your code (you are not showing how score of TestViewController is declared), but according to the error message, you may need to write something like this: Score.text = String(newScore.score) When you want to change the content text shown in a UILabel, you need to change the property text, not UILabel itself. And, Swift is a strictly typed language. When newScore.score is Int, you need to convert it to String explicitly. Using String.init(_:) is one way to convert Int to String.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to Image Literal
I'm following a tutorial and the image literal function auto-populated on the tutorial Image literal is not a thing you type manually. If your tutorial has any parts typing ImageLiteral into a code editor, you should better not rely on the description. Image literals are intended to be automatically generated by Xcode. After you have successfully added an image resource to your project, you can drag the image from the Project navigator to an actual position in the code editor: The detailed behavior may be different in versions of Xcode. Your question is about how to use Xcode and you should better include the version info in your original post. And better use the tag Xcode.
Oct ’21
Reply to When observing a notification that may be posted "on a thread other than the one used to registered the observer," how should I ensure thread-safe UI work?
Should I dispatch to the main queue from within my presentAlert function, or... That's one thing required. But if your issue is really caused by threading problem, there may be many other things to fix. Better try fixing it and test on the TestFlight with as many testers involved as you can.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Text Field doesn't update
Is there a way to show the app launch screen until firebase fully loads, NO. maybe there is any other way? Many apps show sort of Loading View while some sort of communication is going on. Simply, you can show a better word than "nil", or you could show your own Loading View (other than launch screen).
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to App crashes at WKWebView's 'load' method
Can you show the whole message shown in the debug console? I have not tested enough, but recent iOS are eager to detect more unexpected usages than ever. Do you think of anything unusual in the usage of your WKWebView? Showing more context, including the content of stringUrl or other project settings related to WKWebView may help.
Replies
Boosts
Views
Activity
Oct ’21
Reply to ShazamKit API URL
Does anyone know if there is an official URL for the Shazam API and how I can use it? As far as I know, Apple has never announced the Web API for ShazamKit. And the current shazam.com (Shazam is now a family company of Apple) does not have any documentations or links to the API you have shown. So, you may need to research and learn it by yourself and use it on your own risk. (Seems it is not free.)
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Not expected result when changing a variable in a "defer" block, if the variable has observers willSet or didSet.
Thanks for finding and sharing an interesting example. For me, it seems to be a bug of Swift. You should better send a bug report to swift.org.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to NavigationLink destination - Set view programmatically
As far as I read your requirements, you do not seem to have many choices. One possible way, prepare a generic TaskView: struct TaskView: View { let number: Int var body: some View { switch number { case 1: Task01View() case 2: Task02View() case 3: Task03View() //... default: EmptyView() } } } And use it like this: ForEach(0...6, id: \.self) { task in NavigationLink( destination: TaskView(number: task) ) { Text("\(task). Aufgabe") .font(.custom("Chalkduster", fixedSize: 16)) .foregroundColor(Color(UIColor.brown)) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How to make good User Interfaces
@MinhQuang I cannot say what are good User Interfaces, but it seems you have your own good User Interfaces in mind. Please try to explain what is the problem of the current UI and what would be your expected UI. I do not understand what you mean by I can't make the inside park I tried to use List layout but it didn't work out. Hand-drawn sketch would help. Please do not forget to show your current code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Accessing an environmentObject's function in another environmentObject which is created at the same time
The problem is, that is dont only need the billModel in the PDFManger but also everywhere else in the App I do not think that would be an issue, you can do what Dirk-FU said: class PDFManager: ObservableObject { var billModel : BillModel? func saveToDB() { billModel?.addData(billToAdd: bill) } //... } And set PDFManager.billModel on start up of your app: var body: some Scene { WindowGroup { MainView() .environmentObject(billModel) .environmentObject(customerModel) .environmentObject(itemModel) .environmentObject(sheet) .environmentObject(manager) .onAppear(perform: { manager.billModel = billModel billModel.getData() customerModel.getData() itemModel.getData() }) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to 'ColumnNavigationViewStyle' initializer is inaccessible due to 'internal' protection level
Swift 5.5 introduced a new dot leaded notation. SE-0299Extending Static Member Lookup in Generic Contexts Please try this: .navigationViewStyle(.columns)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Imported Image Orientation
If you come here to solve your issue, please try to explain your problem precisely. Please show your code to reproduce the issue, what is the current behavior and what would be the expected behavior. Including screen shots and images would help readers understanding.
Topic: Media Technologies SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Should a delegate property passed into a struct also be declared as weak in the struct?
Should the delegate property in the struct also be marked with weak? It depends on whether it may create a reference cycle or not. In the example code you have shown, hostingController may hold a strong reference to ExampleView.delegate, but it is not held as a strong reference in viewController. (Please start type names with Capital letter, even in a simplified example.) So, you have no need to declare the property ExampleView.delegate as weak. Generally, in case of View structs, you have no need to care about reference cycles if you are using the View in a usual way. But, if you are not using the View in a usual way, or the struct is not a View and it may be used in various ways, you may need to place weak on properties which may make reference cycle. If you do not understand what would be usual nor what might make reference cycles, better use weak even when it is not named delegate.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Will there be Japanese language support for VNRecognizeTextRequest in the near future?
Will this language be supported soon? Apple rarely announces future plans except on some big events like WWDC. It may be included in a minor update of iOS 15 in months, or it will take years, possibly never. You can send an enhance request and wait. But you should not rely on anything else than Apple's official announcements.
Topic: Machine Learning & AI SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How Do You Assign Int To UILabel
When you show your code, please show it as text using Code Block. With showing easily testable code, more readers would try to solve your issue. And in Swift, only type names start with Capital letter. Score or ScoreButton are not Swifty names. And one more, if TestViewController is actually a subclass of ViewController, it might not be appropriate to instantiate it like TestViewController(). This may cause many critical issues. We need to guess some parts of your code (you are not showing how score of TestViewController is declared), but according to the error message, you may need to write something like this: Score.text = String(newScore.score) When you want to change the content text shown in a UILabel, you need to change the property text, not UILabel itself. And, Swift is a strictly typed language. When newScore.score is Int, you need to convert it to String explicitly. Using String.init(_:) is one way to convert Int to String.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Trying to share my videos
If you really want some help, you should better show more context. Especially in this case, it would be better to show the whole code which can reproduce the issue. (Please show the code as text using Code Block.)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Image Literal
I'm following a tutorial and the image literal function auto-populated on the tutorial Image literal is not a thing you type manually. If your tutorial has any parts typing ImageLiteral into a code editor, you should better not rely on the description. Image literals are intended to be automatically generated by Xcode. After you have successfully added an image resource to your project, you can drag the image from the Project navigator to an actual position in the code editor: The detailed behavior may be different in versions of Xcode. Your question is about how to use Xcode and you should better include the version info in your original post. And better use the tag Xcode.
Replies
Boosts
Views
Activity
Oct ’21