Re: [swift-users] Detect if a generic type is numeric

2017-10-01 Thread Dave Reed via swift-users
> On Oct 1, 2017, at 2:32 PM, Glenn L. Austin wrote: > >> >> On Oct 1, 2017, at 8:56 AM, Dave Reed via swift-users >> wrote: >> >> >>> On Sep 21, 2017, at 3:58 PM, V T via swift-users >>> wrote: >>> >>> Hi there! &

Re: [swift-users] Detect if a generic type is numeric

2017-10-01 Thread Dave Reed via swift-users
> On Sep 21, 2017, at 3:58 PM, V T via swift-users > wrote: > > Hi there! > > Is there a best way to check if a given type conforms to numeric protocol > (Integer or FP) at runtime? > > func checkNumeric(_ value: T) { > /* return true if vaiue is Integer or FP */ > /* this will n

Re: [swift-users] Self - requirement

2017-03-14 Thread Dave Reed via swift-users
> On Mar 14, 2017, at 4:15 AM, Quinn The Eskimo! via swift-users > wrote: > > > On 14 Mar 2017, at 06:02, Седых Александр via swift-users > wrote: > >> Please, tell, where I can read about "Self" requirement in protocols? > > The thing that really clarified it for me was Dave Abrahams’s cl

Re: [swift-users] It seems like we really need an #include preprocessor directive?

2017-03-11 Thread Dave Reed via swift-users
> On Mar 11, 2017, at 3:12 PM, Edward Connell via swift-users > wrote: > > Observations about difining an object > • Structs can't inherit and classes shouldn't inherit, final concrete > types should be flat > • Protocols need to be adopted by the final concrete type, otherwise >

[swift-users] question on generics

2017-02-22 Thread Dave Reed via swift-users
I suspect this can't be done (at least not right now), but wanted to check. I'd like to declare a class as a generic that meets a protocol and is also a subclass of some specific type. Something like class Foo (i.e., the T must be both a NSManagedObject or subclass of it and conform to SomeProt

[swift-users] default struct initializer internal even if class declared public

2017-01-18 Thread Dave Reed via swift-users
I’m teaching an iOS with Swift this semester and one of my students pointed out that: struct Person { var firstName: String var lastName: String } does create a default initializer that you can call as: p = Person(firstName: “Dave”, lastName: “Reed”) but if you write: public struct Perso

Re: [swift-users] Core Data auto-generated Swift files errors?

2017-01-16 Thread Dave Reed via swift-users
This would probably be better-suited on the Xcode list than here as I think it's a bug in Xcode. I've had issues when trying out this new CoreData codegen feature. What fixes it for me is to go to: ~/Library/Developer/Xcode/DerivedData and delete the entire directory for the build of my projec

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-13 Thread Dave Reed via swift-users
; in addition to class Event: NSManagedObject . . . >>> >>> Yes, I know in Xcode 8, that last part can now be written for you. >>> >>> Again, if this is the "right way to do it", I'm ok with that, I just >>> wondered if there is a be

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-05 Thread Dave Reed via swift-users
e Reed > On Jan 5, 2017, at 2:35 PM, Pierre Monod-Broca > wrote: > > Hello, > > It looks that you have what you wanted because Event.Entity is an alias of > Event. > > Pierre > >> Le 5 janv. 2017 à 16:47, Dave Reed via swift-users a >> écrit :

[swift-users] make a static/class method return type be the subclass it is called with

2017-01-05 Thread Dave Reed via swift-users
Is there a way to make a static or class method specify the return type be the actual class it is called with? The example code below using protocols/extensions mostly works (the type is [Event.Entity] not [Event] but it seems to work. If I try to make DDRCoreData a base class and Event subclas

Re: [swift-users] private vs. fileprivate on global declaration in Swift3?

2016-09-28 Thread Dave Reed via swift-users
> On Sep 28, 2016, at 3:22 AM, Cao Jiannan via swift-users > wrote: > > Should I use private or fileprivate to declare global variables/consts in > Swift 3? e.g. > > fileprivate let a = 1 > fileprivate class SomeClass { > fileprivate b = 0 > } > > or > > private let a = 1 > private clas

Re: [swift-users] changes to pointer data types in Xcode 8 beta 6

2016-08-16 Thread Dave Reed via swift-users
; <https://developer.apple.com/reference/swift> > > You can also look up the documentation using the "Documentation and API > Reference" menu in Xcode 8 Beta 6, as it's currently updated. > > Sincerely, > Zachary Waldowski > zach...@bignerdranch.com >

[swift-users] changes to pointer data types in Xcode 8 beta 6

2016-08-15 Thread Dave Reed via swift-users
I'm trying to convert the following code (from the Big Nerd Ranch's Freddy JSON parser) that works in Xcode 8 beta 5 and convert it to work with beta 6. Essentially it appears it needs to take a Data object and convert it to a UnsafeBufferPointer if I understand it correctly. /// Creates a

Re: [swift-users] AttributedString gone in Xcode 8 beta 4?

2016-08-02 Thread Dave Reed via swift-users
Makes sense. Thanks. :-) Dave > On Aug 2, 2016, at 12:24 PM, Jordan Rose wrote: > > That was pretty much the rationale for restoring “NS". :-) > >> On Aug 1, 2016, at 14:46, Dave Reed via swift-users >> wrote: >> >> Ah, I thought there was already

Re: [swift-users] Why can't structs inherit from other structs?

2016-08-01 Thread Dave Reed via swift-users
> On Aug 1, 2016, at 8:28 PM, Rick Mann via swift-users > wrote: > > It sure seems natural. > > Is there some reason the language can't allow a sub-struct to add member > variables, such that the whole is treated like a contiguous set of members? > > In my case, I have a rect-like value type

Re: [swift-users] AttributedString gone in Xcode 8 beta 4?

2016-08-01 Thread Dave Reed via swift-users
https://github.com/apple/swift-evolution/blob/master/proposals/0086-drop-foundation-ns.md > && > https://github.com/apple/swift-evolution/commit/bea5eab614b954775754639fb83a957a180152e1#diff-e260ca20577a1e205ea0b72456a21b7f > > On Mon, Aug 1, 2016 at 2:23 PM Dave Reed via swif

[swift-users] AttributedString gone in Xcode 8 beta 4?

2016-08-01 Thread Dave Reed via swift-users
I was updating my project from beta 3 to beta 4 today and it seems AttributedString disappeared. Changing it to NSAttributedString fixed it. I don't see anything in the Release Notes about AttributedString. Is it gone permanently? Or am I doing something wrong? Thanks, Dave Reed _

Re: [swift-users] Learn Objective-C First? and Low Level Understanding of computer

2016-07-30 Thread Dave Reed via swift-users
> On Jul 30, 2016, at 1:36 PM, smd via swift-users > wrote: > > Hello > > I’m interested in learning Swift. Is there a need or benefit to learn > Objective-C first? I’ve done some C, C++, VB 6.0, and VBA / Access in the > past but I’m definitely not a programmer. I want to develop programs f

Re: [swift-users] CGContext endPage method ambiguous (two candidates) Swift 3/Xcode 8

2016-06-17 Thread Dave Reed via swift-users
> On Jun 17, 2016, at 12:28 PM, Joe Groff wrote: > > >> On Jun 16, 2016, at 1:49 PM, Dave Reed via swift-users >> wrote: >> >> I've got a project I had been working on using Swift2.2 and decided to >> migrate to Swift3 (using Xcode 8

Re: [swift-users] expression too complex

2016-06-16 Thread Dave Reed via swift-users
a bug report? > > -- E > >> On Jun 16, 2016, at 2:59 PM, Dave Reed via swift-users >> wrote: >> >> >> Joe, >> >> I had an expression that worked fine with Swift2.2 but Swift3 (Xcode 8 >> version) complains it's too complex: &

Re: [swift-users] expression too complex

2016-06-16 Thread Dave Reed via swift-users
Joe, I had an expression that worked fine with Swift2.2 but Swift3 (Xcode 8 version) complains it's too complex: The variables are of type CGPoint and the function returns a Bool. return (pt.x - p0.x) * (p1.y - p0.y) - (pt.y - p0.y) * (p1.x - p0.x) < 0.0 Thanks, Dave > On Jun 6, 2016,

[swift-users] CGContext endPage method ambiguous (two candidates) Swift 3/Xcode 8

2016-06-16 Thread Dave Reed via swift-users
I've got a project I had been working on using Swift2.2 and decided to migrate to Swift3 (using Xcode 8 beta) before the project gets any bigger. I successfully migrated everything except I have a CGContext for writing to a PDF and calls the endPage() method. For that the compiler responds with

Re: [swift-users] Can't extend a generic type with a non-protocol constraint?

2016-04-18 Thread Dave Reed via swift-users
> On Apr 14, 2016, at 4:58 PM, Jens Alfke via swift-users > wrote: > > It appears that you can’t extend a generic class/struct with a requirement > that a type parameter inherit from a non-protocol: > extension Dictionary where Key : String { … } > The above produces the error “Type ‘Key