Post

Replies

Boosts

Views

Activity

Reply to Text - Formatted HTML
Is there a way to use Text directly, but keeping break lines and lists? Can you show some examples of some formatted text? Generally, Text is not intended to show HTML content. Using the new feature AttributedString of iOS 15, you may be able to show some limited sets of HTML as formatted text, but depends on the actual contents you want to show.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to How should I learn Swift?
One thing you should know is that there is not the best for everyone. You should better spend some time and try as much resource as you can touch. Some Apple's resource would be a good starting point, but it is not clear if it would be the best for you. And forget about Roblox LuaU, experiences of other languages may not always get things better when learning a new language.
Aug ’21
Reply to Weak references
I believe weak references are not required when using self inside the dispatch queues. I do not understand what you mean. There may be many cases you should use weak even when using self inside the dispatch queues.
Topic: Programming Languages SubTopic: Swift 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
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 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 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 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 Text - Formatted HTML
Is there a way to use Text directly, but keeping break lines and lists? Can you show some examples of some formatted text? Generally, Text is not intended to show HTML content. Using the new feature AttributedString of iOS 15, you may be able to show some limited sets of HTML as formatted text, but depends on the actual contents you want to show.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How should I learn Swift?
One thing you should know is that there is not the best for everyone. You should better spend some time and try as much resource as you can touch. Some Apple's resource would be a good starting point, but it is not clear if it would be the best for you. And forget about Roblox LuaU, experiences of other languages may not always get things better when learning a new language.
Replies
Boosts
Views
Activity
Aug ’21
Reply to Can't create ARView for non AR application
The doc says that init(frame:cameraMode:automaticallyConfigureSession:) is only available for iOS 13+, no macOS. Are you sure you made the project for iOS?
Replies
Boosts
Views
Activity
Aug ’21
Reply to Weak references
I believe weak references are not required when using self inside the dispatch queues. I do not understand what you mean. There may be many cases you should use weak even when using self inside the dispatch queues.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to scroll UICollectionView cell automatically according to the time of day
Thanks for the additional explanation. I believe I understand far better. You may need to call scrollToItem at launch time and at every minute (every second?) the next bus is changed.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Why image detail view just show one image from listview?
You have not shown any codes using RowView, But I guess the problem lives here: NavigationLink(destination:  ListDetailsView(docs: datas[0])) { It should be like this: NavigationLink(destination:  ListDetailsView(docs: docs)) {
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Weak references
Whether it may make a reference cycle or not. If you cannot judge it by yourself, better use weak self always.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Weak references
Seems you should better always use weak self, or take enough time to learn about reference cycle.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Closure containing a declaration cannot be used with result builder 'ViewBuilder'
Please show enough code to tell what you can do about this error.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Wallet pass: JSON with binary content/unknown encoding
Can anyone tell me which kind of encoding/file format this is, so I can implement a proper method of opening/parsing this? As far as I see the content shown with less, it seems to be a JSON text written in UTF-32LE. Have you tried to read the content of the file as String using .utf32LittleEndian?
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Aug ’21