Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread zh ao via swift-users
'Default' implementation in protocol extension is used as fail safe. You should not consider it like something super class does. If you want it that way, use class inheritance instead. Zhaoxin Get Outlook for iOS _ From: Rick Mann via swift-users Sen

Re: [swift-users] Why can't we get `URL` equal on the same path?

2016-10-14 Thread zh ao via swift-users
In your opinion, `baseURL` is a factor more important than `path`. I can not unaccept your answer. But I want to know why? Is there a standard on URL equality?  ZhaoXin  Get Outlook for iOS _ From: Greg Parker Sent: 星期六, 十月 15, 2016 05:40 Subject: Re

Re: [swift-users] How to create an iOS project by SPM?

2016-09-20 Thread zh ao via swift-users
I don't think it will be in the near future. I have not used it yet. Does it support Objective-C cross compiling? If it supports Swift only, it may not be designed to do that.  Zhaoxin Get Outlook for iOS On Wed, Sep 21, 2016 at 9:24 AM +0800, "Leo" wrote:

Re: [swift-users] How to create an iOS project by SPM?

2016-09-20 Thread zh ao via swift-users
I don't think you could. According to the release note of Xcode 8, Swift Package Manager can only be used in macOS command line. Zhaoxin Get Outlook for iOS On Wed, Sep 21, 2016 at 12:12 AM +0800, "Leo SHI via swift-users" wrote: Hi guys, I started to use SPM after installing Xco

Re: [swift-users] Variadic parameter in function type

2016-08-29 Thread zh ao via swift-users
It is suggested to put ... part at the end. Zhaoxin Get Outlook for iOS On Mon, Aug 29, 2016 at 1:19 PM +0800, "Jin Wang via swift-users" wrote: Hey guys, Can anyone tell me how you handle the following scenario after SE-0111 gets implemented? let output: (_ items: Any..., _ separ

Re: [swift-users] Is 12:01:00A.M in DataFormatter.localizedString correct?

2016-08-29 Thread zh ao via swift-users
But the beginning of AM/PM is 12, and the end is 11, which is odd to me. I now think the model as a real clock on the wall which use Rome numbers, there are III, VI, IX and XII. So definetly there is no zero hour on the clock. Thanks all. Zhaoxin Get Outlook for iOS On Mon, Aug 29, 2016 at

Re: [swift-users] [Docs] - Documentation for the standard library

2016-08-01 Thread zh ao via swift-users
go to swift.org Zhaoxin Get Outlook for iOS On Mon, Aug 1, 2016 at 7:16 PM +0800, "Adrian Brink via swift-users" wrote: Hi, on the github repo for swift (https://github.com/apple/swift) it says that many of the docs are out-of-date. Is there a community effort to fix that, because

Re: [swift-users] Why can't Swift instance methods call class methods without qualification?

2016-07-01 Thread zh ao via swift-users
Your conclusion is the same as mine and you disagree with what I said? :/ mine: > Swift forces you to use class name to alert you on the fact that static > variables and methods (may) affect the other instances of the class as > static variables are shared between instances. That does make sense.

Re: [swift-users] Why can't Swift instance methods call class methods without qualification?

2016-07-01 Thread zh ao via swift-users
16, at 6:47 PM, zh ao via swift-users > wrote: > > You should be aware of using static methods as it may change static > variables, which affects all instances of that class. Normally I think > static methods is designed to use outside the class instance, if you have > to us

Re: [swift-users] Why can't Swift instance methods call class methods without qualification?

2016-06-30 Thread zh ao via swift-users
Swift has its own suggested patterns on calling methods. For example, it suggests you calling instance methods directly inside class. It also forces you calling self.method() in closure that without @noescape. As well as the static method with the class name in your question. Those are different fr

Re: [swift-users] Why can't Swift instance methods call class methods without qualification?

2016-06-30 Thread zh ao via swift-users
Just a choice made by the language designers to distinguish the call at the call site. You should be aware of using static methods as it may change static variables, which affects all instances of that class. Normally I think static methods is designed to use outside the class instance, if you hav

Re: [swift-users] Can Swift 2.3 frameworks be used with a Swift 3.0 app?

2016-06-27 Thread zh ao via swift-users
Not with current Swift 3. Currently, the developing team make efforts on releasing Swift 3 together with iOS 10 and macOS 10.12 in September. The primary goal of this release is to solidify and mature the Swift language and development experience. While source breaking changes to the language have

Re: [swift-users] Can Swift 2.3 frameworks be used with a Swift 3.0 app?

2016-06-27 Thread zh ao via swift-users
You need to wait until they are promised to work with 2.3 or 3.0. If you can get the source code, you can use migration tool and compile the framework yourself. Zhaoxin On Mon, Jun 27, 2016 at 6:29 PM, Ted Bradley via swift-users < swift-users@swift.org> wrote: > Ah, I wasn’t being clear :) > >

Re: [swift-users] Can Swift 2.3 frameworks be used with a Swift 3.0 app?

2016-06-27 Thread zh ao via swift-users
I don't know which frameworks you talking about. The Foundation framework is definitely different. But Cocoa and Cocoa Touch should be the same. Zhaoxin On Mon, Jun 27, 2016 at 6:04 PM, Ted Bradley via swift-users < swift-users@swift.org> wrote: > Can Swift 2.3 frameworks be used with a Swift 3

Re: [swift-users] Hexadecimal floating-point literals

2016-06-26 Thread zh ao via swift-users
I think it avoids the confusion. You can use print((0xabc).beef) instead. Zhaoxin On Sun, Jun 26, 2016 at 3:50 PM, Toni Suter via swift-users < swift-users@swift.org> wrote: > Hi, > > I have a question regarding hexadecimal floating-point literals. According > to the Lexical Structure ( > https:

Re: [swift-users] Swift 3 preview 1 in Xcode 8 and Lowercase enum cases

2016-06-21 Thread zh ao via swift-users
e ​num should be case-sensitive. If you find it otherwise, you should file a bug. Zhaoxin On Wed, Jun 22, 2016 at 5:48 AM, Stéphane Lizeray wrote: > Hello, > > The following enum > > enum X { > > case A_B > > > } > > is translated to: > > enum X { > > case a_b > > > } > > which is fine. > > But

Re: [swift-users] Swift 3 Release

2016-06-19 Thread zh ao via swift-users
It probably will. In WWDC videos, it was said you can use both Swift 2.3 and 3.0 in Xcode 8. Xcode 8 will be released together with iOS 10 and macOS 10.12. Swift 2.3 is provided to those who don't want to move to Swift 3.0 rapidly. Zhaoxin On Mon, Jun 20, 2016 at 4:22 AM, Brent Royal-Gordon via s

Re: [swift-users] #selector with Swift 3?

2016-06-17 Thread zh ao via swift-users
Can you give more information on the function showRescale, is it function showRescale() or showRescale(a:foo)? Or have you tried case let x where x == #selector(showRescale): Zhaoxin On Fri, Jun 17, 2016 at 9:33 PM, Maury Markowitz via swift-users < swift-users@swift.org> wrote: > I was asked to

Re: [swift-users] Redeclaration of guard variable is ignored at top-level

2016-06-17 Thread zh ao via swift-users
You should file a bug on the first sample. Zhaoxin On Fri, Jun 17, 2016 at 1:43 PM, Saagar Jha via swift-users < swift-users@swift.org> wrote: > Looks like a bug…strangely, lldb’s giving number: Int = 5678. > > > On Thu, Jun 16, 2016 at 10:18 PM Martin R via swift-users < > swift-users@swift.org

Re: [swift-users] inout params seem to have undefined behavior

2016-06-13 Thread zh ao via swift-users
According to the latest Swift 3 docs “As an optimization, when the argument is a value stored at a physical address in memory, the same memory location is used both inside and outside the function body. The optimized behavior is known as call by reference; it satisfies all of the requirements of t

Re: [swift-users] inout params seem to have undefined behavior

2016-06-11 Thread zh ao via swift-users
inout says it will copy into the function and copy back after the function is finished. But the order is unknown. So I think the example, print(acopy) // prints "[1, 2, 99]" (e.g. a let variable changed!) i ​s a bug as the value changed inside of the function, before the function returns. ​Swif

Re: [swift-users] Class extension issues (Xcode 7.3 (7D175))

2016-06-07 Thread zh ao via swift-users
Is this a correct useage of namespace? As far as I know, there is not a solution for namespace in Swift. Or should I say that Swift is not support namespace? Zhaoxin On Wed, Jun 8, 2016 at 7:48 AM, Victor Leong via swift-users < swift-users@swift.org> wrote: > Hey guys, > > I'm starting to see p

Re: [swift-users] Struct lazy Variable doubt

2016-05-27 Thread zh ao via swift-users
I am a little odd about it too. However, if you give it a try, you will get the results. var lazyStruct = lazyTest(lazyVariable: 5, someProperty: 6) lazyStruct.lazyVariable // 5 var anotherStruct = lazyTest(lazyVariable:nil, someProperty: 7) anotherStruct.lazyVariable // 10 ​Everything wor

Re: [swift-users] Bool with Foundation framework, can convert to AnyObject

2016-05-25 Thread zh ao via swift-users
Thanks, Jordan. Zhaoxin On Thu, May 26, 2016 at 12:33 AM, Jordan Rose wrote: > > On May 25, 2016, at 02:11, zh ao via swift-users > wrote: > > We were told that Bool can't downcast to AnyObject in Swift. However, with > Foundation framework, we can. > > do { >

[swift-users] Bool with Foundation framework, can convert to AnyObject

2016-05-25 Thread zh ao via swift-users
We were told that Bool can't downcast to AnyObject in Swift. However, with Foundation framework, we can. do { let a:Bool = true let object:AnyObject = a as AnyObject object.dynamicType // __NSCFBoolean.Type let b:Bool = object as! Bool b // true } This feature work

[swift-users] Dictionary can accept Bool as a Value, but my own function can't

2016-05-24 Thread zh ao via swift-users
See the code: do { var dictionary = Dictionary() func update(value:T, key:String) { dictionary.updateValue(value, forKey: key) } let aBool = true let key = "testBool" update(aBool, key: key) // cannot invoke 'update' with an argument list of type '

Re: [swift-users] function advancedBy() bugs

2016-05-17 Thread zh ao via swift-users
artIndex internally contains a fault > endIndex(str.endIndex, it should be its own endIndex, range.endIndex), > which leads the issue. > > > Zhaoxin > > On Wed, May 18, 2016 at 12:02 AM, Dmitri Gribenko > wrote: > >> On Tue, May 17, 2016 at 5:46 AM, zh ao via swift-users >>

Re: [swift-users] function advancedBy() bugs

2016-05-17 Thread zh ao via swift-users
I just make a clearer example. do { var str = "abcdefg" var str1 = str + "hijklmn" var range = str.startIndex.. wrote: > On Tue, May 17, 2016 at 5:46 AM, zh ao via swift-users > wrote: > > It seams that I encountered bugs in function advancedBy

Re: [swift-users] function advancedBy() bugs

2016-05-17 Thread zh ao via swift-users
The second half on mutating is wrong. Please ignore that. Zhaoxin On Tue, May 17, 2016 at 8:47 PM, zh ao wrote: > Xcode Version 7.3.1 (7D1014), swift 2.2 along with Xcode. > > Zhaoxin > > On Tue, May 17, 2016 at 8:46 PM, zh ao wrote: > >> It seams that I encountered bugs in function advancedBy

Re: [swift-users] function advancedBy() bugs

2016-05-17 Thread zh ao via swift-users
Xcode Version 7.3.1 (7D1014), swift 2.2 along with Xcode. Zhaoxin On Tue, May 17, 2016 at 8:46 PM, zh ao wrote: > It seams that I encountered bugs in function advancedBy(). > > //: Playground - noun: a place where people can play > > > import Foundation > > > do { > > var str = "abcdefg" >

[swift-users] function advancedBy() bugs

2016-05-17 Thread zh ao via swift-users
It seams that I encountered bugs in function advancedBy(). //: Playground - noun: a place where people can play import Foundation do { var str = "abcdefg" var range = str.startIndex.. Self @warn_unused_result public func advancedBy(n: Self.Distance, limit: Self) -> Self }

Re: [swift-users] ?? operator question

2016-04-19 Thread zh ao via swift-users
Thanks for your explanation. I still think the compiler should not be that smart, causing only itself could understanding what is going on. It will be a nightmare. Owen On Tue, Apr 19, 2016 at 7:09 PM, Marco Feltmann via swift-users < swift-users@swift.org> wrote: > Just guessed since I try to

Re: [swift-users] ?? operator question

2016-04-18 Thread zh ao via swift-users
pr 18, 2016 at 9:49 PM, Erica Sadun wrote: > > On Apr 18, 2016, at 7:23 AM, zh ao via swift-users > wrote: > > I do think there is something wrong here. > > // Xcode 7.3.1, Swift 2.2 > > let t1: Int? = 2 // struct Int? > let y = t1 ?? "abcdf" // error &

Re: [swift-users] ?? operator question

2016-04-18 Thread zh ao via swift-users
I do think there is something wrong here. // Xcode 7.3.1, Swift 2.2 let t1: Int? = 2 // struct Int? let y = t1 ?? "abcdf" // error let x = t1 ?? NSFont(name: "", size: 0) // x: NSObject? for x, how could it be NSObject?, as t1 is a struct? zhaoxin On Mon, Apr 18, 2016 at 6:59 PM, Marco Feltman