Re: Instantiate NSString from NSURL in Swift

2015-02-26 Thread Charles Srstka
On Feb 23, 2015, at 1:52 PM, Fritz Anderson wrote: > > On 23 Feb 2015, at 8:18 AM, Juanjo Conti > wrote: >> >> I'm translating some code from Objective-C to Swift and in the middle of >> that, i found this problem. >> >> theUrl is an instance of NSURL >> >> th

Re: Instantiate NSString from NSURL in Swift

2015-02-23 Thread Charles Srstka
On Feb 23, 2015, at 1:52 PM, Fritz Anderson wrote: > > This is written in haste, and few people are experts… > >theURL.host may yield nil (host is declared String!, implicitly > unwrapped, but optional). > >theURL.host?.lowercaseString will short-circuit and be evaluated as nil > if

Re: Instantiate NSString from NSURL in Swift

2015-02-23 Thread Quincey Morris
On Feb 23, 2015, at 11:52 , Kyle Sluder wrote: > > So the type of > foo?.lowercaseString is String?. Yes, I agree, so the OP’s *original* error message was correct, but the question is what is the type of ‘foo?.lowercaseString!’, and that depends on the precedence of the “!” operator. The ac

Re: Instantiate NSString from NSURL in Swift

2015-02-23 Thread Fritz Anderson
On 23 Feb 2015, at 8:18 AM, Juanjo Conti wrote: > > I'm translating some code from Objective-C to Swift and in the middle of > that, i found this problem. > > theUrl is an instance of NSURL > > theUrl.host?.lowercaseString > > compiles ok. > > But > > NSString(string: theUrl.host?.lowercaseS

Re: Instantiate NSString from NSURL in Swift

2015-02-23 Thread Kyle Sluder
On Mon, Feb 23, 2015, at 01:48 PM, Marco S Hyman wrote: > lowerCaseString is a non optional property. Therefore it makes no sense > to > write someString.lowercaseString? or someString.lowercaseString! It's chained through an optional access though. So the type of foo?.lowercaseString is String?.

Instantiate NSString from NSURL in Swift

2015-02-23 Thread Juanjo Conti
Hi! I'm translating some code from Objective-C to Swift and in the middle of that, i found this problem. theUrl is an instance of NSURL theUrl.host?.lowercaseString compiles ok. But NSString(string: theUrl.host?.lowercaseString) don't. It says "Value of optional type 'String?' no unwrapped; d