Post

Replies

Boosts

Views

Activity

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 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 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 US Central timezone in Swift?
it appears that the TimeZone initializer is looking for an abbreviation, rather than a full string. I do not understand why you think so. As far as I tried, "America/Chicago" returned the thing you would like: if let tz = TimeZone(identifier: "America/Chicago") { print(tz) //-> America/Chicago (fixed) print(tz.identifier) //-> America/Chicago print(tz.abbreviation(for: Date())) //-> Optional("CDT") print(tz.isDaylightSavingTime()) //-> true print(tz.secondsFromGMT()) //-> -18000 } else { print("Unknown TimeZone identifier") } Or you can write some Swift 5 version of the code shown by Claude31: if let chicagoTimezoneIdentifier = TimeZone.knownTimeZoneIdentifiers.filter({ $0.contains("Chicago") }).first, let chicagoTimezone = TimeZone(identifier: chicagoTimezoneIdentifier) { print(chicagoTimezone) //-> America/Chicago (fixed) //... }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to converting to "stringValue" not working on IOS 15.0(beta)
Your code [[@"blink,turnLeft,turnRight" stringValue] UTF8String] causes compile-time error in Xcode 12.5.1 (not beta). No visible @interface for 'NSString' declares the selector 'stringValue' So, it would never run on the IOS 14.7. I guess you have simplified the shown code, but that does not help solving your issue. As the error message is clearly stating, the method stringValue is not defined for NSString. Unfortunately, some wrong codes might seemingly work in very limited cases. But you should not rely on such codes would always work.
Topic: App & System Services SubTopic: General Tags:
Aug ’21
Reply to SwiftUI Picker.onchange not changing.
The double line spacing is a forum bug. Have you tried Paste and Match Style? am I doing this wrong? I guess you are doing something wrong. As far as I tried your code (I needed to fill many parts by guess, though), I could get Rx Symbol Rate changed to: ... in the console. Can you show enough code to reproduce the issue? I guess your ViewModel is sort of broken.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to Is it possible to update SwiftUI 2.0 project to Swift 3.0?
I guess you mean SwiftUI 3 by Swift 3.0. (There is no official labeling on versions of SwiftUI. And the current version of Swift is 5.4 and the coming version is 5.5. Swift 3.0 is too old.) is it possible to do that? No simple way. Generally, you need to modify your code according to the changes in iOS 15 (or other new platform versions) as well as other changes of APIs. The project made using SwiftUI 2 would still be a valid project even in Xcode 13/SwiftUI 3, but you may need to replace deprecated/removed APIs in your code and test your project wholly to check if some behavior changes would affect your app.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to FileHandle class has a lot of deprecated methods. What do I use instead?
FileHandle.close (FileHandle.closeFile() ?) -> close() throws (As far as I checked, close() is not deprecated.) FileHandle.readDataToEndOfFile -> readToEnd() throws The header doc says that deprecated APIs may throw exceptions (this means Objective-C exceptions which cannot be handled in Swift safely). So their replacements may very probably be throws-methods which may throw Swift errors and can be handled in Swift safely. You would be able to find replacements searching in Instance Methods in the documentation of FileHandle.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21