Post

Replies

Boosts

Views

Activity

Reply to Limit available app languages
I don't want to delete localization files, because they contain some useful translations that I will use in the future. You may need to move unready localized resources when archiving, and then move them back when you want to test them. Not sure there may be some better ways for you.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to How to create UIHostingController and pass environmentObject?
When you show some code, you should better show it as text using Code Block. With easily testable code shown, more readers would be involved solving your issue. (Of course, images are very useful for some additional info.) Modifiers like environmentObject(_:) would make an instance of a certain private type, like ModifiedContent<AttachmentView, _EnvironmentKeyWritingModifier<AttachmentViewModel?>> (may change in versions of SwiftUI). So, you cannot specify the generic parameter of UIHostingController as AttachmentView, neither cannot use ModifiedContent<...> explicitly as Swift compiler hides details of some View. It seems you have not many options: Avoid subclassing UIHostingController, that requires the generic parameter specified. Avoid any modifiers. With the latter, you can write something like this: class AttachmentViewController: UIHostingController<AttachmentView> { let model = AttachmentViewModel() init() { let attachmentView = AttachmentView(model: model) super.init(rootView: attachmentView) } @objc required dynamic init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } struct AttachmentView: View { var model: AttachmentViewModel var body: some View { InnerAttachemntView() .environmentObject(model) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to Getting started with PHP ..
As you can see in the WARNING, PHP is not considered to be a supported feature of recent macOS, so it is not appropriate to discuss about it here. You can find many sites on the web which are explaining PHP on macOS.
Topic: Safari & Web SubTopic: General Tags:
Aug ’21
Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
how can I get a UIViewController instance when the app starts, such that I can pass it into the SDK function for dialog display? If it is not possible to do it in AppDelegate.swift, can it be done some where else? If your project have an automatically generated SceneDelegate.swift, you may do it in it. But it is hard to say if it really would work or not, without knowing what showConsentDialog does and how your project is organized.
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to Xcode 12.5 StackView & Constraints - Where is the Attributes Inspector -> Distribution Menu?
As far as I can see, you have not put a UIStackView on your storyboard. The view may be named as stackView, but is not a UIStackView. It's just a UIView. If you had successfully put a UIStackView, it would be shown with a sandwich icon: I am not sure if you have mistaken or your Xcode is malfunctioning, but you should better remove your Stack View and go back to the part where tutorial shows how to put UIStackView.
Aug ’21
Reply to Practical Use of Combine's Subject
In your viewDidLoad() you declare a local variable cancellable, which is disposed at the end of the scope. In your case, it is at the end of viewDidLoad. Please try something like this: override func viewDidLoad() { super.viewDidLoad() self.cancellable = currentValueSubject .sink { value in print("New value: \(value)") } currentValueSubject.send(5) currentValueSubject.send(10) //currentValueSubject.send(completion: .finished) currentValueSubject.send(15) //cancellable.cancel() }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Cannot find 'ContentView' in scope
I guess you need to solve your another question in the right way. Why do you not respond to comments or answers?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Limit available app languages
I don't want to delete localization files, because they contain some useful translations that I will use in the future. You may need to move unready localized resources when archiving, and then move them back when you want to test them. Not sure there may be some better ways for you.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to create UIHostingController and pass environmentObject?
When you show some code, you should better show it as text using Code Block. With easily testable code shown, more readers would be involved solving your issue. (Of course, images are very useful for some additional info.) Modifiers like environmentObject(_:) would make an instance of a certain private type, like ModifiedContent<AttachmentView, _EnvironmentKeyWritingModifier<AttachmentViewModel?>> (may change in versions of SwiftUI). So, you cannot specify the generic parameter of UIHostingController as AttachmentView, neither cannot use ModifiedContent<...> explicitly as Swift compiler hides details of some View. It seems you have not many options: Avoid subclassing UIHostingController, that requires the generic parameter specified. Avoid any modifiers. With the latter, you can write something like this: class AttachmentViewController: UIHostingController<AttachmentView> { let model = AttachmentViewModel() init() { let attachmentView = AttachmentView(model: model) super.init(rootView: attachmentView) } @objc required dynamic init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } struct AttachmentView: View { var model: AttachmentViewModel var body: some View { InnerAttachemntView() .environmentObject(model) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Getting started with PHP ..
As you can see in the WARNING, PHP is not considered to be a supported feature of recent macOS, so it is not appropriate to discuss about it here. You can find many sites on the web which are explaining PHP on macOS.
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to animation(nil) replacement in SwiftUI 3.0 (iOS 15)
The doc of animation(_:) says Deprecated Use withAnimation or animation(_:value:) instead. Have you tried?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to UIImage.init - imageLiteralResourceName crashing during App review
Can you show the whole definition of getCurrentDayNumber?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
how can I get a UIViewController instance when the app starts, such that I can pass it into the SDK function for dialog display? If it is not possible to do it in AppDelegate.swift, can it be done some where else? If your project have an automatically generated SceneDelegate.swift, you may do it in it. But it is hard to say if it really would work or not, without knowing what showConsentDialog does and how your project is organized.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to OS X + Swift + Xcode : Programmatically transition from one view controller to another
You can instantiate the target view controller through the storyboard, and use any of the presentation method like present(_:animator:).
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to SwiftUI + Xcode + OS X: Center container on screen
As far as I know, there is no pure-SwiftUI way. You may need to work with NSWindow.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to UserDefaults on App Launch
Can you show your code checking UserDefaults including enough context to guess what may be happening?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Xcode 12.5 StackView & Constraints - Where is the Attributes Inspector -> Distribution Menu?
As far as I can see, you have not put a UIStackView on your storyboard. The view may be named as stackView, but is not a UIStackView. It's just a UIView. If you had successfully put a UIStackView, it would be shown with a sandwich icon: I am not sure if you have mistaken or your Xcode is malfunctioning, but you should better remove your Stack View and go back to the part where tutorial shows how to put UIStackView.
Replies
Boosts
Views
Activity
Aug ’21
Reply to Practical Use of Combine's Subject
In your viewDidLoad() you declare a local variable cancellable, which is disposed at the end of the scope. In your case, it is at the end of viewDidLoad. Please try something like this: override func viewDidLoad() { super.viewDidLoad() self.cancellable = currentValueSubject .sink { value in print("New value: \(value)") } currentValueSubject.send(5) currentValueSubject.send(10) //currentValueSubject.send(completion: .finished) currentValueSubject.send(15) //cancellable.cancel() }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Swift + OS X + Xcode : Change NavigationLink destination and text programtically
You should better use Code Block properly. More readable code would appeal to more readers.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to UITextFiled.selectedTextRange doesn't work
As far as I tried it put cursor to the end of text field. Where have you put the line? Is the textField become first responder?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to UITextFiled.selectedTextRange doesn't work
I tried following code in the same place Where is that same place?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21