Post

Replies

Boosts

Views

Activity

Reply to Running FileManager.default.enumerator on different tasks
Any ideas why this is happening? I was under the impression FileManager was thread safe? Generally, FileManager is considered to be thread safe, but you should better not expect that is declaring FileManager solves all the issues about concurrency. In fact, there's a description: FileManager Threading Considerations The methods of the shared FileManager object can be called from multiple threads safely. However, if you use a delegate to receive notifications about the status of move, copy, remove, and link operations, you should create a unique instance of the file manager object, assign your delegate to that object, and use that file manager to initiate your operations. I guess there may be other cases you should create a unique instance of the file manager object in addition to delegate cases. Can you try using a unique instance of FileManager instead of FileManager.default and tell us what happens?
Topic: App & System Services SubTopic: General Tags:
Nov ’21
Reply to Swift switch statement optimization
Al already noted, semantically switch-cases are evaluated from top to bottom. With a switch statement on an enum with a large (over 100) number of cases would it make sense to replace the switch with a dictionary of closures? That depends on your enum. As far as I checked switch on simple enum cases like: switch value { case .case001: break case .case002: break case .case003: break ... case .case100: break } It is optimized into a simple multiway branching as found in C-switch statement, even in optimization level -Onone. SwitchCaseOptimization`MyClass.switchMethod(_:): 0x100006750 <+0>: pushq %rbp 0x100006751 <+1>: movq %rsp, %rbp 0x100006754 <+4>: movb %dil, %al 0x100006757 <+7>: movb $0x0, -0x8(%rbp) 0x10000675b <+11>: movq $0x0, -0x10(%rbp) 0x100006763 <+19>: movb %al, -0x8(%rbp) 0x100006766 <+22>: movq %r13, -0x10(%rbp) -> 0x10000676a <+26>: movzbl %al, %eax 0x10000676d <+29>: movq %rax, -0x18(%rbp) 0x100006771 <+33>: movq -0x18(%rbp), %rax 0x100006775 <+37>: leaq 0x144(%rip), %rcx ; SwitchCaseOptimization.MyClass.switchMethod(SwitchCaseOptimization.MyCases) -> () + 368 0x10000677c <+44>: movslq (%rcx,%rax,4), %rax 0x100006780 <+48>: addq %rcx, %rax 0x100006783 <+51>: jmpq *%rax (Please be careful, too strong optimization like -O would make whole switch statement into nop, in a simplified all break example as shown above.) I do expect this optimization would occur in Simple enum cases, no rawValue Enum cases with Int as rawValue, the value range is not huge I have not tried with enums with some cases having associated values or enum cases with String as rawValue. (Seems internal case representation is a small int even when its rawValues are String.) So, can you show the definition of your enum?
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Getting started with creating swift playground
Swift Playground on macOS. Thanks for clarifying. (But Swift Playgrounds might be the right name of it.) Start Swift Playgrounds. Click See All beside More Playgrounds. And then click See All beside Starting Points. And then you can choose any of the templates to start with. (https://support.apple.com/en-mo/guide/playgrounds/itc2207c0869/mac) I could not find a good tutorial using the Blank template, please share your experience when you find some.
Nov ’21
Reply to Pass swift func result to func
First of all, you should better not put the parameter declarations directly ahead of some statement in a closure: Amplify.API.get(request: request) {result in switch result { case .success(let data): // Do success stuff case .failure(let apiError): // Do failure stuff } } And you will see you can do it in the same way: Amplify.API.get(request: request) {result in myFunction(result, myParam1, myParam2) }
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Axie Infinity
The dev forum is not a place for notification of release dates of some specific app. Find the site of the developer of the app.
Nov ’21
Reply to Viewcontroller layout in iOS 15
Can you show the example which shows different layouts between iOS 14 and iOS 15?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to React Native iOS TestFlight build crashes only on iOS 12 version
React Native is not a framework of Apple's. You should better contact to the author of the framework or the Microsoft app center.
Replies
Boosts
Views
Activity
Nov ’21
Reply to Auto complete no longer available in swift playgrounds?
Which Swift Playgrounds? For iPadOS or for macOS? As far as I tried with Swift Playgrounds 3.4.1 for macOS, auto complete feature seems to be working.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to EXC_CRASH (SIGABRT) iOS 15.1
Seems the YooKassaPayments may be doing some hacks which do not work in iOS 15.1 . Contact to the author of the library or find another better one. (The library may already have some known issue with iOS 15.1 .)
Replies
Boosts
Views
Activity
Nov ’21
Reply to Running FileManager.default.enumerator on different tasks
Any ideas why this is happening? I was under the impression FileManager was thread safe? Generally, FileManager is considered to be thread safe, but you should better not expect that is declaring FileManager solves all the issues about concurrency. In fact, there's a description: FileManager Threading Considerations The methods of the shared FileManager object can be called from multiple threads safely. However, if you use a delegate to receive notifications about the status of move, copy, remove, and link operations, you should create a unique instance of the file manager object, assign your delegate to that object, and use that file manager to initiate your operations. I guess there may be other cases you should create a unique instance of the file manager object in addition to delegate cases. Can you try using a unique instance of FileManager instead of FileManager.default and tell us what happens?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Swift switch statement optimization
Al already noted, semantically switch-cases are evaluated from top to bottom. With a switch statement on an enum with a large (over 100) number of cases would it make sense to replace the switch with a dictionary of closures? That depends on your enum. As far as I checked switch on simple enum cases like: switch value { case .case001: break case .case002: break case .case003: break ... case .case100: break } It is optimized into a simple multiway branching as found in C-switch statement, even in optimization level -Onone. SwitchCaseOptimization`MyClass.switchMethod(_:): 0x100006750 <+0>: pushq %rbp 0x100006751 <+1>: movq %rsp, %rbp 0x100006754 <+4>: movb %dil, %al 0x100006757 <+7>: movb $0x0, -0x8(%rbp) 0x10000675b <+11>: movq $0x0, -0x10(%rbp) 0x100006763 <+19>: movb %al, -0x8(%rbp) 0x100006766 <+22>: movq %r13, -0x10(%rbp) -> 0x10000676a <+26>: movzbl %al, %eax 0x10000676d <+29>: movq %rax, -0x18(%rbp) 0x100006771 <+33>: movq -0x18(%rbp), %rax 0x100006775 <+37>: leaq 0x144(%rip), %rcx ; SwitchCaseOptimization.MyClass.switchMethod(SwitchCaseOptimization.MyCases) -> () + 368 0x10000677c <+44>: movslq (%rcx,%rax,4), %rax 0x100006780 <+48>: addq %rcx, %rax 0x100006783 <+51>: jmpq *%rax (Please be careful, too strong optimization like -O would make whole switch statement into nop, in a simplified all break example as shown above.) I do expect this optimization would occur in Simple enum cases, no rawValue Enum cases with Int as rawValue, the value range is not huge I have not tried with enums with some cases having associated values or enum cases with String as rawValue. (Seems internal case representation is a small int even when its rawValues are String.) So, can you show the definition of your enum?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Getting started with creating swift playground
Swift Playground on macOS. Thanks for clarifying. (But Swift Playgrounds might be the right name of it.) Start Swift Playgrounds. Click See All beside More Playgrounds. And then click See All beside Starting Points. And then you can choose any of the templates to start with. (https://support.apple.com/en-mo/guide/playgrounds/itc2207c0869/mac) I could not find a good tutorial using the Blank template, please share your experience when you find some.
Replies
Boosts
Views
Activity
Nov ’21
Reply to unrecognized selector sent to instance 0x1dae7dbf8'
Hard to say something with the log shown. You should better visit the supporting site or a community site of React native to get better responses sooner.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Pass swift func result to func
First of all, you should better not put the parameter declarations directly ahead of some statement in a closure: Amplify.API.get(request: request) {result in switch result { case .success(let data): // Do success stuff case .failure(let apiError): // Do failure stuff } } And you will see you can do it in the same way: Amplify.API.get(request: request) {result in myFunction(result, myParam1, myParam2) }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Axie Infinity
The dev forum is not a place for notification of release dates of some specific app. Find the site of the developer of the app.
Replies
Boosts
Views
Activity
Nov ’21
Reply to Getting started with creating swift playground
Are you working with Swift Playgrounds (an app for iPadOS and macOS)? Or Xcode Playground (a part of Xcode)?
Replies
Boosts
Views
Activity
Nov ’21
Reply to Filtering a NSTreeController / NSOutlineView
Seems you do not like to make your question more appealing to readers.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ScrollView overlapping NavigationView bar
There might be someone who would not hesitate to dive into some external links. Better wait for such reader would find this thread. Good luck.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Changing title of button also changes font and size.
Can you show enough code to reproduce the issue?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Filtering a NSTreeController / NSOutlineView
Can you show enough code to reproduce the issue?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21