Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-08 Thread C. Keith Ray via swift-users
good point - type safety would prevent it from compiling. also, the controllers are subclasses of NSFetchedResultsController but the delegate method takes a different type: NSFetchedResultsController NSManagedObject != NSFetchRequestResult -- C. Keith Ray Senior Software Engineer / Traine

Re: [swift-users] overloading methods where only difference is optional vs. non-optional type

2017-10-10 Thread C. Keith Ray via swift-users
nope. it's the same as this example: func funny() -> Int { return 1 } func funny() -> String { return "2" } print(funny()) // the compiler doesn't know which one you want. // the above doesn't compile. // error: forloop.playground:8:1: error: ambiguous use of 'funny()' You have to have some

Re: [swift-users] overloading methods where only difference is optional vs. non-optional type

2017-10-10 Thread C. Keith Ray via swift-users
You need to know that the NAME of a method or function isn't just outside the parenthesis. The name of func IsTextEmpty(foo : String?) -> Bool? is "IsTextEmpty(foo:)" and the name of func IsTextEmpty(text : String?) -> Bool is "IsTextEmpty(text:)" The argument labels ar

Re: [swift-users] How can I set NSButton's keyEquivalent to the Escape key?

2017-11-02 Thread C. Keith Ray via swift-users
try "\u{1b}" -- C. Keith Ray Senior Software Engineer / Trainer / Agile Coach * http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf > On Nov 2, 2017, at 8:39 AM, 李某某 via swift-users wrote: > > With Objective-C I can simple make it. > [button setKeyEquivalent:"\E"]; > > However s

[swift-users] How to store ref to any kind of function, and call with it argument list?

2017-11-03 Thread C. Keith Ray via swift-users
In the code below, I'm trying to store a reference to a function with any number of arguments, with any return type. And I want to be able to invoke it. Help? See the comments with "***" typealias Void = () func equalTypes(_ me: [Any.Type], _ other: [Any.Type]) -> Bool { guard me.coun

Re: [swift-users] How to store ref to any kind of function, and call with it argument list?

2017-11-03 Thread C. Keith Ray via swift-users
handling the common cases of no arguments, 1 > argument, 2 arguments, etc up to some fixed number of arguments that you > consider “enough”. Use a switch on the type of the function. > > Slava > >> On Nov 3, 2017, at 2:21 PM, C. Keith Ray via swift-users >> mailto:swift-

Re: [swift-users] How to store ref to any kind of function, and call with it argument list?

2017-11-05 Thread C. Keith Ray via swift-users
spes...@apple.com>> wrote: >>> >>> Unfortunately we don’t have a way to invoke a function with a runtime >>> argument list because that would require runtime code generation in the >>> most general case. >>> >>> I would hack arou

[swift-users] abs() Bug?

2017-12-12 Thread C. Keith Ray via swift-users
Should these be consistent? All crashing or none crashing? print(abs(Int8.min)) // crash print(abs(Int16.min)) // crash print(abs(Int32.min)) // prints -2147483648 print(abs(Int64.min)) // crash Should this be reported by Radar or another mechanism? I'm using this as a replacement: func sa

Re: [swift-users] "Month 13 is out of bounds"

2018-01-02 Thread C. Keith Ray via swift-users
what are your system settings for Language & Region? > On Jan 2, 2018, at 10:10 AM, David Wood via swift-users > wrote: > > In XCode, I’ve built a little …mathematical utility program for my own use. > It’s a Swift 4, Cocoa & Foundation-based program targeted at High Sierra. But > it’s doing

Re: [swift-users] بخصوص: Swift 4.0 bug in concurrent array access

2018-01-08 Thread C. Keith Ray via swift-users
A simple mutation counter works in the single-threaded case for i in x { print(i) if middle_of_x { x.add(y) } // bang! } The add while enumerating should change the mutation counter, and the implicit getting of next value for the for-loop should see the current mutation counter doesn't equa

Re: [swift-users] Swift 4.0 bug in concurrent array access

2018-01-08 Thread C. Keith Ray via swift-users
It's up to the programmer-user to impose thread-safety around an array or other data structure. The compiler doesn't know if you want to allow multiple threads to write and read multiple array members, or prevent all but one thread to read and write multiple array members, or allow multiple rea

Re: [swift-users] Clarification about the Swift API Design Guide - Initializer and factory methods calls

2018-01-09 Thread C. Keith Ray via swift-users
I think the advice is really to avoid unnecessary "helper" words in the names let foreground = Color(havingRGBValuesRed: 32, green: 64, andBlue: 128) "Having" and "and" are unnecessary... Should be let foreground = Color(red: 32, green: 64, blue: 128) let newPart = factory.makeWi