Re: CGFloat and literal floats in Swift

2015-07-26 Thread Tim Fletcher
Slightly off topic; I would love to see some form of what Scala calls implicits in swift. For exactly this reason. On Mon, 27 Jul 2015 05:10 Rick Mann wrote: > > > On Jul 26, 2015, at 20:57 , Jens Alfke wrote: > > > > > >> On Jul 26, 2015, at 4:50 PM, Quincey Morris < > quinceymor...@rivergates

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Rick Mann
> On Jul 26, 2015, at 20:57 , Jens Alfke wrote: > > >> On Jul 26, 2015, at 4:50 PM, Quincey Morris >> wrote: >> >> No. Swift doesn’t convert between numeric types automatically, so Double —> >> CGFloat produces an error. > > I’m guessing this is only a problem when building 32-bit? Because

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Jens Alfke
> On Jul 26, 2015, at 4:50 PM, Quincey Morris > wrote: > > No. Swift doesn’t convert between numeric types automatically, so Double —> > CGFloat produces an error. I’m guessing this is only a problem when building 32-bit? Because in 64-bit, CGFloat is equivalent to Double, so there shouldn’t

Re: NSPropertyListSerialization weirdness

2015-07-26 Thread Gary L. Wade
When the file arrives, verify that the contents of it have also arrived. It's possible you may just be processing that a file was created but nothing yet has been put into it. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ > On Jul 26, 2015, at 2:28 PM, Robert Martin wrote: > > I

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Quincey Morris
On Jul 26, 2015, at 17:42 , Rick Mann wrote: > > So, why can I do this? > > let n : NSNumber = M_PI That’s bridged, not converted. :) The Swift compiler has built-in knowledge of what can be bridged, and does a typecast or value conversion according to context. __

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Rick Mann
> On Jul 26, 2015, at 16:50 , Quincey Morris > wrote: > > On Jul 26, 2015, at 16:38 , Rick Mann wrote: >> >> So, is a literal 0.0 not of type Double? > > No, it’s a numeric literal, so it has no numeric type. However your ‘addArc’ > function requires CGFloat parameters. Literal 0.0 is conv

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Quincey Morris
On Jul 26, 2015, at 16:38 , Rick Mann wrote: > > So, is a literal 0.0 not of type Double? No, it’s a numeric literal, so it has no numeric type. However your ‘addArc’ function requires CGFloat parameters. Literal 0.0 is convertible to CGFloat, but Double M_PI isn’t convertible automatically.

Re: Generics Question

2015-07-26 Thread Michael de Haan 
> . That’s why I was asking about a more realistic example of the problem > you’re trying to solve. Point taken. This was just a “trivial” … well it seems not that trivial…example to deepen my understanding of Generics. So, I thank you, and will repost with a more specific example if and whe

Re: Generics Question

2015-07-26 Thread Quincey Morris
On Jul 26, 2015, at 16:30 , Michael de Haan  wrote: > > func genericFor(s:String) -> T { > >return T(s)! // error. ’T’ cannot be constructed because it has no > accessible initializers > } This *generic* definition asks for an invocation of ‘init (_ s: String)’ *for any type that satis

Re: Generics Question

2015-07-26 Thread Marco S Hyman
> func genericFor(s:String) -> T { > >return T(s)! // error. ’T’ cannot be constructed because it has no > accessible initializers > } At compile time there is no way of determining if T has an initializer that takes a string. You could do something like this protocol Ini

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Rick Mann
> On Jul 26, 2015, at 16:34 , Quincey Morris > wrote: > > On Jul 26, 2015, at 16:29 , Rick Mann wrote: >> >> addArc(CGPoint(x: 0, y: 0), 50.0, 0.0, M_PI) > > The problem in this case is that M_PI is a Double variable in Swift, not a > compile time constant like in Obj-C. You will unfortunat

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Quincey Morris
On Jul 26, 2015, at 16:29 , Rick Mann wrote: > > addArc(CGPoint(x: 0, y: 0), 50.0, 0.0, M_PI) The problem in this case is that M_PI is a Double variable in Swift, not a compile time constant like in Obj-C. You will unfortunately have to wrap it in CGFloat(), then the constants should work fine

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Rick Mann
Also weird, I only have to cast the last two arguments, not the second. > On Jul 26, 2015, at 16:07 , Quincey Morris > wrote: > > On Jul 26, 2015, at 15:57 , Rick Mann wrote: >> >> I'm finding it a bit cumbersome to use CGFloat in graphics code in Swift, >> because the compiler won't let me

Re: Generics Question

2015-07-26 Thread Michael de Haan 
> > > What you really need to do depends on what you’re really trying to achieve. Sorry, it’s been a long day :-) I am really trying to understand this. So….. given this… and I think this will make sense now, * func intFor(s:String) -> Int { return Int(s)! } func ge

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Rick Mann
> On Jul 26, 2015, at 16:07 , Quincey Morris > wrote: > > On Jul 26, 2015, at 15:57 , Rick Mann wrote: >> >> I'm finding it a bit cumbersome to use CGFloat in graphics code in Swift, >> because the compiler won't let me pass a floating-point literal to a >> parameter that takes a CGFloat. I

Re: Generics Question

2015-07-26 Thread Quincey Morris
On Jul 26, 2015, at 15:49 , Michael de Haan  wrote: > > func genericTFor(s:String) -> T { > >return T(s)! > > } > > > > let intFromStr = intFor("9") > let intFromStrB:Double = genericTFor("9") > > > in other words, write a generic function that will return an Int, Doub

Re: CGFloat and literal floats in Swift

2015-07-26 Thread Quincey Morris
On Jul 26, 2015, at 15:57 , Rick Mann wrote: > > I'm finding it a bit cumbersome to use CGFloat in graphics code in Swift, > because the compiler won't let me pass a floating-point literal to a > parameter that takes a CGFloat. I have to wrap them all in CGFloat(). I’m not seeing this. Do you

Re: Updating a screensaver from 10.6 to 10.10

2015-07-26 Thread Graham Cox
> On 27 Jul 2015, at 7:11 am, Gabriel Zachmann wrote: > > in Scripting Bridge to retrieve photos from iPhoto-now-Photos, Don’t use Scripting Bridge for this. Since 10.9 there’s MLMediaLibrary and related classes which provide access to various media, including iPhoto and Photos content. —Gr

CGFloat and literal floats in Swift

2015-07-26 Thread Rick Mann
I'm finding it a bit cumbersome to use CGFloat in graphics code in Swift, because the compiler won't let me pass a floating-point literal to a parameter that takes a CGFloat. I have to wrap them all in CGFloat(). This seems really, well, cumbersome. Why does the language impose this burden? Is

Re: Generics Question

2015-07-26 Thread Michael de Haan 
Oops… I should have called it genericTfor etc as in: >>> func intFor(s:String) -> Int { return Int(s)! } func genericTFor(s:String) -> T { return T(s)! } let intFromStr = intFor("9") let intFromStrB:Double = genericTFor("9") in oth

Generics Question

2015-07-26 Thread Michael de Haan 
I’m writing a coreData helper which will rely on Generics. Could I get some input? I have synthesized the problem down to this somewhat nonsensical code. From Playground: func intFor(s:String) -> Int { return Int(s)! } func genericIntFor(s:String) -> T { r

Re: NSPropertyListSerialization weirdness

2015-07-26 Thread Robert Martin
Thanks Jens, I’ll test for NSNulls instead. I know the dictionary is valid because after I read it with dictionaryWithContentsOfFile:, I log it, and it ‘looks' fine… > On Jul 26, 2015, at 5:44 PM, Jens Alfke wrote: > > >> On Jul 26, 2015, at 2:28 PM, Robert Martin wrote: >> >> I get a null

Re: NSPropertyListSerialization weirdness

2015-07-26 Thread Jens Alfke
> On Jul 26, 2015, at 2:28 PM, Robert Martin wrote: > > I get a null, and an error (200) that the plist contains null. > > Before I make that call, I put in a check for nulls, but none are found: You’re checking for nil pointers. (Which are illegal in Foundation collections, so you’ll never f

NSPropertyListSerialization weirdness

2015-07-26 Thread Robert Martin
I’m having some issues. I’m tracking a folder that is I watch via kqueue, and if a .plist arrives, I process it immediately. The plist contains a dictionary, which is successfully read with dictionaryWithContentsOfFile:. If I log the dictionary description, it is accurate. The dictionary only co

Updating a screensaver from 10.6 to 10.10

2015-07-26 Thread Gabriel Zachmann
Dear all, I have written a screensaver , but unfortunately, I didn't have the time to update the source code sine OS X 10.7 . It is still working so-so, but showing signs of code aging. Now I would like to bring the source code up to date. Does anybody know of some guidelines , or a list of hin

Re: NSTableView - kill the blue (Obj-C)

2015-07-26 Thread 2551
> On 26 Jul 2015, at 22:17, Ken Thomases wrote: > > The right approach is to subclass NSTableRowView. It's not hard. Why do you > resist it? > OK, got it. Thanks for the pointers. Much appreciated! Best Phil ___ Cocoa-dev mailing list (Cocoa-

Re: NSTableView - kill the blue (Obj-C)

2015-07-26 Thread Ken Thomases
On Jul 26, 2015, at 7:25 AM, 2551 <2551p...@gmail.com> wrote: > I’ve been struggling with NSTableView for the last two days. All I want to do > is ensure the alternative “gray” highlight is used on a selection > consistently instead of the heavy blue. My first question is why do you want to tri

Re: WKWebView loading local files (and relative paths)

2015-07-26 Thread Tim Fletcher
Solved Sorry for the noise List. It was user error. I wasn’t using the WebView correctly. Tim > On 26 Jul 2015, at 07:30, Tim Fletcher wrote: > > Sorry, massive omission on my part. I'm building a desktop OS X 10.10.4 > application. Using the latest Xcode > > On Sunday, July 26, 2015, Jens A

NSTableView - kill the blue (Obj-C)

2015-07-26 Thread 2551
I’ve been struggling with NSTableView for the last two days. All I want to do is ensure the alternative “gray” highlight is used on a selection consistently instead of the heavy blue. Here’s my code: -(void) killBlue { NSInteger selectedRow = [_tableView selectedRow]; if ([_tableView se