Re: [swift-users] Pass Value of Variable to a Function

2016-09-06 Thread Jens Alfke via swift-users
> On Sep 6, 2016, at 9:39 PM, Michael Sheaver via swift-users > wrote: > > I know that in some languages, if you prepend the passed parameter with a > '$', as in $propertyName, the receiving function knows to use the contents of > the variable named propertyName (in this case "calendar") inst

Re: [swift-users] Pass Value of Variable to a Function

2016-09-06 Thread Michael Sheaver via swift-users
Hi Zhao, Many thanks for your response, and I will give this a try. However, I think that I might have used a bad example for the bigger question I was trying to ask, and for that I am sorry. The question that I am really trying to address here is: Is there a more Swift-y way to, when passing

Re: [swift-users] Why we need `__attribute__((sentinel(0,1)))`?

2016-09-06 Thread Greg Parker via swift-users
> On Sep 6, 2016, at 6:50 PM, 哀殿 via swift-users wrote: > > Hello Swift community, > > I found `__attribute__((sentinel(0,1)))` at > https://github.com/apple/swift-clang/blob/c52d85ede49adaec457400697b1d4c1b7ea12881/test/Analysis/variadic-method-types.m#L46. > > But I can't imagine how differ

Re: [swift-users] Pass Value of Variable to a Function

2016-09-06 Thread Shawn Erickson via swift-users
I am trying to understand why you are trying to do this. Can you provide a better example for why you need to do this? -Shawn ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Pass Value of Variable to a Function

2016-09-06 Thread Zhao Xin via swift-users
I think you messed up with `Locale` and `NSLocale`. `Locale` is a struct in Swift 3 to replace the legacy `NSLocale`. The latter is a class, it has an inner `structure` called `NSLocale.Key`. For `Locale`, there is no `NSLocale.Key`. All there keys are instance properties in `Locale`. So in your s

[swift-users] Pass Value of Variable to a Function

2016-09-06 Thread Michael Sheaver via swift-users
I am trying to build a table of current locale properties in code, and have encountered issues with trying to pass the value of a variable to a function: let currentLocale = Locale(identifier: "en_US") let calendar1 = currentLocale.calendar // "gregorian (fixed)" let propertyName = "calend

[swift-users] Why we need `__attribute__((sentinel(0,1)))`?

2016-09-06 Thread ???? via swift-users
Hello Swift community, I found `__attribute__((sentinel(0,1)))` at https://github.com/apple/swift-clang/blob/c52d85ede49adaec457400697b1d4c1b7ea12881/test/Analysis/variadic-method-types.m#L46. But I can't imagine how different it is from the `__attribute__((sentinel))`. So,why we need `__att

Re: [swift-users] Can we `override var hashValue`?

2016-09-06 Thread Zhao Xin via swift-users
Thanks Lou. In addition to what Jordan and Dmitri have said, I think part of the > confusion is that you are assuming hash values are implicitly used in an > equality check. They are not. They are used when your instances are added > to certain types of collections. ​You are very nice. But I w

Re: [swift-users] Can we `override var hashValue`?

2016-09-06 Thread Lou Zell via swift-users
> > My question is, apple equals banana, but their hashValues (in their own > types) don't. What's wrong here? ​ Hi Zhao. In addition to what Jordan and Dmitri have said, I think part of the confusion is that you are assuming hash values are implicitly used in an equality check. They are not.

Re: [swift-users] DWARF without DSYM

2016-09-06 Thread Dmitry Shevchenko via swift-users
Reading more about Swift modules under swift/docs. I start to believe that there's always one "main" swift module per executable, is that right? In that case, a pure Swift program poses no issues with debugging, there's always an "entry point" Swift module that can be specified in N_AST and from t

Re: [swift-users] Can we `override var hashValue`?

2016-09-06 Thread Jordan Rose via swift-users
As I’ve said before, this doesn’t work. let x: Fruit = Apple(“a”, shape: .medium) let y: Fruit = Apple(“a”, shape: .big) print(x == y) // will print true If you want == to behave differently for subclasses, it needs to call a method that can be overridden. Static overloads will not produce the s

[swift-users] Query: Code-obfuscation Techniques

2016-09-06 Thread Pandey, Sunil Y via swift-users
Hi, Can somebody please help me in getting the more appropriate way of doing Code-obfuscation. How to obfuscate API names and pretty much everything so that once we give build(ipa file) so nobody can extract and see which kind of API's, techniques and methods have been used? Most affective code

Re: [swift-users] Extend int arrays to be hashable?

2016-09-06 Thread Brent Royal-Gordon via swift-users
> On Sep 6, 2016, at 12:38 AM, Jean-Denis Muys via swift-users > wrote: > > I suppose I could make my HashableIntArray “have-a” Array, but then I > would have to reimplement all the Array API with boilerplate code, which is > really inelegant at best. > > What did I miss? Nothing. In the cur

[swift-users] Extend int arrays to be hashable?

2016-09-06 Thread Jean-Denis Muys via swift-users
Hello, I am struggling to convince Swift 3 (from Xcode 8 beta 6) to let me use an array of Int as dictionary keys. It doesn’t work out of the box, because an array is not hashable: var answers: [[Int]:Bool] = [:] // error: Type [Int] does not conform to Protocol Hashable One way to work aroun