Re: Predicate warning from text view

2015-07-07 Thread Shane Stanley
On 25 Oct 2014, at 10:23 am, Martin Wierschin wrote: >> I have a subclass of a text view in my app. When I double-click on other >> than a word (ie, a space or return), I get entries like these in the Console: >> >> _NSExtensionIsSafeExpressionForObjectWithSubquerySubstitutions: Expression >>

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 17:51 , Greg Parker wrote: > > The power of `case` outside `switch` was increased at some point. It's likely > that the documentation has not caught up. You should file a bug report. I did. Thanks for the confirmation, though! -- Rick Mann rm...@latencyzero.com __

Re: Any way to combine for and if-let?

2015-07-07 Thread Greg Parker
> On Jul 7, 2015, at 5:30 PM, Rick Mann wrote: > > Thanks. I was looking at the Swift reference. The docs seem to be incorrect: > > https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Patterns.html#//apple_ref/swift/grammar/pattern > > "

Re: How to get Unicode's "General Category" of a character?

2015-07-07 Thread Dmitry Markman
Hi Gerriet first of all it’s unicode/uchar.h header (not utypes.h) I think it would be the best to download ICU distribution from http://site.icu-project.org/download/55#TOC-ICU4C-Download download sources and build it in order to build you have to do the following download and unarchive ic

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 17:30 , Roland King wrote: > > 1) If you’re sure it’s not nil, which for that particular case of an > enumerator from a filemanager I’d agree it’s not (can’t make one work in a > playground to test) then just force-unwrap it > 2) As concise as ‘for case let url as NSURL in

Re: Any way to combine for and if-let?

2015-07-07 Thread Roland King
> On 8 Jul 2015, at 08:26, Quincey Morris > wrote: > > On Jul 7, 2015, at 16:58 , Rick Mann wrote: >> >> Also, the enumerator is a NSDirectoryEnumerator. It returns AnyObject type, >> so wouldn't there have to be an NSURL cast in there somewhere? > > > Try: > >> for case let url as NSURL

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
Thanks. I was looking at the Swift reference. The docs seem to be incorrect: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Patterns.html#//apple_ref/swift/grammar/pattern "There are two type-casting patterns, the is pattern and the as

Re: Any way to combine for and if-let?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 17:28 , Greg Parker wrote: > > for case let item as NSURL in Yes, but you can’t honestly tell me you’re proud of that syntax, can you? ;) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests o

Re: Any way to combine for and if-let?

2015-07-07 Thread Greg Parker
> On Jul 7, 2015, at 4:58 PM, Rick Mann wrote: > >> On Jul 7, 2015, at 16:52 , Quincey Morris >> wrote: >> >>> On Jul 7, 2015, at 16:42 , Rick Mann wrote: >>> >>> for item in enumerator! >> >> Like this: >> >>> for case let item? in enumerator! >> >> (Yes, it’s stupid.) > > Hmm. It does

Re: Any way to combine for and if-let?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 16:58 , Rick Mann wrote: > > Also, the enumerator is a NSDirectoryEnumerator. It returns AnyObject type, > so wouldn't there have to be an NSURL cast in there somewhere? Try: > for case let url as NSURL in enumerator The way to figure these things out is to start with a sw

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 16:52 , Quincey Morris > wrote: > > On Jul 7, 2015, at 16:42 , Rick Mann wrote: >> >> for item in enumerator! > > Like this: > >> for case let item? in enumerator! > > (Yes, it’s stupid.) Hmm. It doesn't seem to like that: '?' pattern cannot match values of type 'Ele

Re: Any way to combine for and if-let?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 16:42 , Rick Mann wrote: > > for item in enumerator! Like this: > for case let item? in enumerator! (Yes, it’s stupid.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator co

Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
Is there any way to combine the for and if-let into one line that gives me unwrapped NSURL objects to work on? I believe the enumerator (which came from NSFileManager) will only have valid NSURLs in it. for item in enumerator! { if let url = item as? NSURL { l

Re: selectText of NSTextField on focus

2015-07-07 Thread Richard Charles
> On Jul 7, 2015, at 8:27 AM, Willeke wrote: > >> Op 6 jul. 2015, om 18:15 heeft Richard Charles het >> volgende geschreven: >> >> Does anyone have any insight into what is going on? >> > The animation of the focus ring isn't finished. If the focus ring is switched > off, the text is select

Sizing NSScrollView width to exactly fit NSTableView

2015-07-07 Thread Matthew LeRoy
Hi, I’m trying to figure out how to correctly calculate the required width of an NSScrollView such that it will exactly fit the NSTableView inside, with no horizontal scroller and no “filler column” to the right of the last column in the table. The number of columns in the table changes based

Re: selectText of NSTextField on focus

2015-07-07 Thread Willeke
> Op 6 jul. 2015, om 18:15 heeft Richard Charles het > volgende geschreven: > > Does anyone have any insight into what is going on? > The animation of the focus ring isn't finished. If the focus ring is switched off, the text is selected. Safari's Address and Search field calls setSelectedRan

Re: selectText of NSTextField on focus

2015-07-07 Thread Richard Charles
> On Jul 6, 2015, at 5:49 PM, Joel Norvell wrote: > > Hi Richard, > > When the instance of your NSTextField subclass becomes first responder, you > have access to the NSText object (the field editor) and I believe you can use > its methods to select the text. (I don't see why you can't, but s

Re: How to get Unicode's "General Category" of a character?

2015-07-07 Thread Gerriet M. Denkmann
> On 7 Jul 2015, at 19:33, Dmitry Markman wrote: > > ICU’s > > u_charType Looks exactly like what I need. But: are the headers and the library on my Mac? There is /usr/lib/libicucore.A.dylib which might contain u_charType, but I cannot find any headers (e.g. utypes.h). Do I have to download

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Greg Weston
>> If you ask the wrong question, you get a wrong answer. :) > > Whether or not it was the wrong question is debatable. Honestly I find that assertion suspect considering that you've moved the goalposts three times. ___ Cocoa-dev mailing list (Cocoa-d

Re: How to get Unicode's "General Category" of a character?

2015-07-07 Thread Dmitry Markman
ICU’s u_charType and after that you can use // http://www.fileformat.info/info/unicode/category/index.htm std::tuple u_charTypeName(UCharCategory c) { switch (c) { /*case U_UNASSIGNED:*/ case U_GENERAL_OTHER_TYPES: return std::make_tuple("Cn","Other, Not Assigned

How to get Unicode's "General Category" of a character?

2015-07-07 Thread Gerriet M. Denkmann
Given a character (a Unicode code point, to be exact) like U+FF0B (FULLWIDTH PLUS SIGN), I want to know the General Category of this. For this example it would be “Sm" (aka. Math_Symbol or Symbol, Math). I could download the current version of UnicodeData.txt and parse it. But this looks not very

Re: Swift Enums and CoreData

2015-07-07 Thread Rick Aurbach
Ah, I see what you’re getting at. This is interesting. Previously when I’ve wanted to implement things like this I’ve used Transformable attributes, which provide an automatic packing/unpacking feature using a packing/unpacking class that I specify in the data model. It is necessary to be caref

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 01:49 , Quincey Morris > wrote: > > On Jul 7, 2015, at 01:39 , Rick Mann wrote: >> >> The problem arises when you want to initialize more than one variable in >> that block of work. > > If you ask the wrong question, you get a wrong answer. :) Whether or not it was the

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 01:39 , Rick Mann wrote: > > The problem arises when you want to initialize more than one variable in that > block of work. If you ask the wrong question, you get a wrong answer. :) You can use a tuple: > let (thumbURL, isHero) = > { > () -> (String?, Bool) in >

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 01:37 , Quincey Morris > wrote: > > On Jul 7, 2015, at 01:33 , Rick Mann wrote: >> >> Yeah, there doesn't seem to be an elegant way to do it > > Actually, there is: > >> let thumbURL: String? = >> { >> for imgD in images >> { >> if let isHero = im

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 01:33 , Rick Mann wrote: > > Yeah, there doesn't seem to be an elegant way to do it Actually, there is: > let thumbURL: String? = > { > for imgD in images > { > if let isHero = imgD["is_hero"] as? Bool where isHero, > let t = im

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Rick Mann
Yeah, there doesn't seem to be an elegant way to do it, so I gave up and used a var. > On Jul 7, 2015, at 01:31 , Quincey Morris > wrote: > > On Jul 7, 2015, at 01:21 , Rick Mann wrote: >> >> let thumbURL: String? >> for imgD in images >> { >> if let isHero = imgD

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 01:21 , Rick Mann wrote: > > let thumbURL: String? > for imgD in images > { > if let isHero = imgD["is_hero"] as? Bool where isHero, > let t = imgD["thumbnail_signed_src"] as? String > { >

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 01:16 , Quincey Morris > wrote: > > On Jul 7, 2015, at 01:08 , Rick Mann wrote: >> >> But I can't get Swift 2 to let me. > > You’ve left a path through the code that doesn’t set ‘someString’. So, you’ll > need to add: > >> else >> { >> someString = nil >> } > > t

Re: Possible to defer initialization of let variable?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 01:08 , Rick Mann wrote: > > But I can't get Swift 2 to let me. You’ve left a path through the code that doesn’t set ‘someString’. So, you’ll need to add: > else > { > someString = nil > } to the ‘if’. ___ Cocoa-dev mailin

Possible to defer initialization of let variable?

2015-07-07 Thread Rick Mann
I thought I saw some Swift code that did this: let someString : String? if some things { // some stuff someString = // some other stuff } // use someString But I can't get Swift 2 to let

Re: cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Charles Srstka
On Jul 7, 2015, at 2:47 AM, Rick Mann wrote: > > >> On Jul 7, 2015, at 00:46 , Charles Srstka wrote: >> >> You don’t have an NSString. You have a String. It works differently. > > Well, they're toll-free bridged, and substringToIndex() is a method on > NSString (or so I thought). Anyway, it

Re: cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Roland King
The bug is really that they haven’t documented the new String method so you only get the old (and still-existing) NSString method. I did find it in some documentation which pointed to online documentation (you can tell by the lag) so I went to prefs, updated my docsets, and now I don’t have it

Re: cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 00:22 , Roland King wrote: > > If you want to use an NSString method with the same name as a String one, > cast to an NSString, ( s as NSString ) The other thing to be really, really careful of when bridging is that all indexes and ranges derived from NSString API are counti

Re: cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Stephen J. Butler
You should file a documentation bug. The signature is actually: func substringFromIndex(index: String.Index) -> String So what you really want I believe is: s = s.substringToIndex(advance(s.endIndex, -1)) On Tue, Jul 7, 2015 at 2:02 AM, Rick Mann wrote: > What? The docs say that substringToI

Re: cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Roland King
The docs for NSString say that substringToIndex is declared like that. If you looked at the autocomplete when you typed it in you’d see it wants an Index, that’s a method on String. And no it’s not in the documentation but it is in the API diffs and autocomplete gets it right (for me at least) a

Re: Swift enums with raw values

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 00:02 , Rick Mann wrote: > > I want to implement some support for HTTP Headers in enums, such that I can > write this: > > extension > NSMutableURLRequest > { > func > set(inHeader : String, _ inVal : String) > { > self.setValue(inVal.rawValue,

cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Rick Mann
What? The docs say that substringToIndex is declared like this: func substringToIndex(_ to: Int) -> String So, why can't I call that here: extension NSURL { func normalizedURLByAppendingPathComponent(var inComponent : String) -> NSURL { var s = self.absoluteString;

Swift enums with raw values

2015-07-07 Thread Rick Mann
I want to implement some support for HTTP Headers in enums, such that I can write this: extension NSMutableURLRequest { func set(inHeader : String, _ inVal : String) { self.setValue(inVal.rawValue, forHTTPHeaderField: inHeader.rawValue()) } } and

Re: Unable to connect IBOutlet in Swift Xcode 7b2

2015-07-07 Thread Rick Mann
> On Jul 6, 2015, at 23:22 , Kyle Sluder wrote: > > On Mon, Jul 6, 2015, at 07:57 PM, Rick Mann wrote: >> >>> On Jul 6, 2015, at 17:54 , Charles Srstka wrote: >>> >>> I’ve occasionally had issues getting Xcode to connect outlets and actions. >>> My workaround for it is to open the Assistant