[swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Jens Alfke via swift-users
I may be missing something obvious, but I can’t find a library function that 
maps a Dictionary to another Dictionary, transforming the keys and/or values. 
The only method I’ve found is the regular map(), which results in an Array. 
Does this just not exist in the standard library?

—Jens
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Subview does not report frame size

2016-08-29 Thread Saagar Jha via swift-users
Bugs with Apple’s frameworks (such as UIKit) are generally better filed as a 
radar.

Saagar Jha



> On Aug 29, 2016, at 09:10, Martin Romañuk via swift-users 
>  wrote:
> 
> In Xcode 8 beta 6, asking for frame or bounds of a subview, both are reported 
> as (0,0,1000,1000) which is incorrect.
> The subview was added to a UIViewController view in storyboard and it is 
> contrained to 240 points of width.
> 
> This works fine in Xcode 7, maybe this is not swift related, more like UIKit.
> 
> Regards,
> – Martin –
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Subview does not report frame size

2016-08-29 Thread Martin Romañuk via swift-users
In Xcode 8 beta 6, asking for frame or bounds of a subview, both are reported 
as (0,0,1000,1000) which is incorrect.
The subview was added to a UIViewController view in storyboard and it is 
contrained to 240 points of width.

This works fine in Xcode 7, maybe this is not swift related, more like UIKit.

Regards,
– Martin –

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Weak references in generic types

2016-08-29 Thread Howard Lovatt via swift-users
Hi,

I am wanting to use weak references in generic data structures; in the
example below Array, but in general any generic type. I can almost get it
to work :(

My experiments started off well; the following works:

// Array of weak references OK
struct WeakReference {
weak var value: T?
}
class C {
var i: Int = 0
}
let c = C() // Strong reference to prevent collection
let weakCs = [WeakReference(value: c)] // OK
print("C: \(weakCs[0].value!.i)") // 0


I can add a protocol:

// Array of weak references that implements a protocol OK
protocol P: AnyObject { // Note AnyObject
var i: Int { get }
}
class CP: P {
var i: Int = 0
}
let cP = CP() // Strong reference to prevent collection
let weakCPs = [WeakReference(value: cP)] // OK
print("CP: \(weakCPs[0].value!.i)") // 0


But when I want an array of weak references to the protocol I get an error:

// Array of weak references of a protocol not OK
let weakPs: [WeakReference] = [WeakReference(value: cP)] // Using 'P' as
a concrete type conforming to protocol 'AnyObject' is not supported
print("P: \(weakPs[0].value!.i)") // 0


Is there something I have missed?

The error message, "Using 'P' as a concrete type conforming to protocol
'AnyObject' is not supported", implies that it is a temporary limitation of
the compiler; is this going to be fixed? Should I lodge a bug report?

Thanks in advance for any advice,

  -- Howard.
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Swift 2.2.1 => Swift 3.0-dev problems with 4 benchmarks game programs

2016-08-29 Thread Isaac Gouy via swift-users
Most of the contributed benchmarks game programs have now been converted from 
Swift 2.2.1 and compile with Swift 3.0-dev.

There are still 4 programs that haven't been converted, which use 
UnsafeMutableRawPointer.

Fixed programs contributed via:

http://benchmarksgame.alioth.debian.org/play.html

:would be welcome --




http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees=swift=4

http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees=swift=5

http://benchmarksgame.alioth.debian.org/u64q/program.php?test=knucleotide=swift=1

http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot=swift=2
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Ambiguity passing `Any?` to generic constructor

2016-08-29 Thread Jens Alfke via swift-users
I’m making a little utility struct that needs to be able to wrap an arbitrary 
value, which may be an optional, and be able to tell whether it’s nil. So I 
declared it like this (I’ve removed the interesting/useful parts of the code 
leaving just the constructors and one property):

public struct check {
let actual: T?

public init(_ a: T) {
actual = a
}

public init(_ a: T?) {
actual = a
}

public var isNil: Bool {
return actual == nil
}
}

This works fine, except when I try to use it with a value of type `Any?`:

let str: String = "Hi"
check(str).isNil// false

let maybe: String? = nil
check(maybe).isNil  // true

let hmm: Any? = nil
check(hmm).isNil// Error: “Ambiguous use of ‘init'"

(I agree that `Any?` is sort of a weird type; in my code it represents a value 
that might be a JSON object. NSJSONSerialization parses to type `Any`, but 
there might not be a value, so it becomes an Optional or Any?.)

This worked in Swift 2.2, but after upgrading to Swift 3 [in the latest Xcode 8 
beta] the compiler started complaining.

How can I fix the `check` struct's constructor(s) to make this work?

—Jens___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Martin R via swift-users
Done: https://bugs.swift.org/browse/SR-2514 .

Martin
(Resent as text mail. I apologize for the previous HTML-only mail.)

2016-08-29 10:51 GMT+02:00 Quinn "The Eskimo!" via swift-users
:
>
> On 27 Aug 2016, at 07:45, Martin R via swift-users  
> wrote:
>
>> Is it intentional that the description method of Data returns only the 
>> number of bytes, but not a hex dump of the contents (as NSData did)?
>
> It doesn’t really matter if it was intentional or not; if it’s annoying then 
> you should file a bug about it anyway.  [I’d file my own but it’d go into 
> Radar and you wouldn’t be able to see it )-: ]
>
> Share and Enjoy
> --
> Quinn "The Eskimo!"
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Martin R via swift-users
Done: https://bugs.swift.org/browse/SR-2514 .MartinAm 29.08.2016 um 10:51 schrieb Quinn The Eskimo! via swift-users :On 27 Aug 2016, at 07:45, Martin R via swift-users  wrote:Is it intentional that the description method of Data returns only the number of bytes, but not a hex dump of the contents (as NSData did)? It doesn’t really matter if it was intentional or not; if it’s annoying then you should file a bug about it anyway.  [I’d file my own but it’d go into Radar and you wouldn’t be able to see it )-: ]Share and Enjoy--Quinn "The Eskimo!"    Apple Developer Relations, Developer Technical Support, Core OS/Hardware___swift-users mailing listswift-users@swift.orghttps://lists.swift.org/mailman/listinfo/swift-users___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Swift Support Framworks Issues

2016-08-29 Thread Pandey, Sunil Y via swift-users
Hi All,

Please  let me know if anybody have


1.   Alternative or better option for below mentioned frameworks

2.   If anybody can point out security issues in the below mentioned 
framework?


a.   https://github.com/jrendel/SwiftKeychainWrapper

b.  https://github.com/ashleymills/Reachability.swift

c.   https://github.com/SwiftyJSON/SwiftyJSON

Best Regards,
Sunil

__
This e-mail (and any attachments), is confidential and may be privileged. It 
may be read, copied and used only by intended recipients. Unauthorized access 
to this e-mail (or attachments) and disclosure or copying of its contents or 
any action taken in reliance on it is unlawful. Unintended recipients must 
notify the sender immediately by e-mail/phone & delete it from their system 
without making any copies or disclosing it to a third person.
_
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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

2016-08-29 Thread Zhao Xin via swift-users
How about this?

func output(_ separator: String, _ terminator: String, _ items: Any...) {

print(items, separator, terminator)

}

output(",", "\n", "Apple", "Banana")


Zhaoxin

On Mon, Aug 29, 2016 at 3:47 PM, Jin Wang  wrote:

> Hey Zhao,
>
> Thanks for your reply, but then i can’t use the default value `print`
> which is the print function Swift provides. Any idea?
>
> Cheers,
> Jin
>
> On 29 Aug. 2016, at 5:44 pm, zh ao  wrote:
>
> 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" <
> swift-users@swift.org> wrote:
>
> Hey guys,
>>
>> Can anyone tell me how you handle the following scenario after SE-0111
>> 
>>  gets
>> implemented?
>>
>> let output: (_ items: Any..., _ separator: String, _ terminator: String)
>> -> Void = print
>> output("Apple", "Banana", ",", "\n”)
>> // Error: Missing argument for parameter #2 in call
>>
>> Thanks,
>> Jin
>>
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] [swift-dev] New Swift Snapshots Available!

2016-08-29 Thread Michael Ferenduros via swift-users
> crashes llvm. Giving the typechecker a hint
> Umanaged(s)

Oops, make that Unmanaged.passRetained(s)

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] remove "Example" from multiline playground markup

2016-08-29 Thread Ray Fix via swift-users
With Xcode playground markup, if I write a multiline Swift code example such as:


for item in collection {
   print(item)
}


The rendered markup it always has the header “Example”  

Is there any way to write multiline code, or modify a stylesheet so that the 
heading “Example” is supressed?

Thank you,
Ray Fix
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Quinn "The Eskimo!" via swift-users

On 27 Aug 2016, at 07:45, Martin R via swift-users  
wrote:

> Is it intentional that the description method of Data returns only the number 
> of bytes, but not a hex dump of the contents (as NSData did)? 

It doesn’t really matter if it was intentional or not; if it’s annoying then 
you should file a bug about it anyway.  [I’d file my own but it’d go into Radar 
and you wouldn’t be able to see it )-: ]

Share and Enjoy
--
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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

2016-08-29 Thread Jin Wang via swift-users
Hey Zhao,

Thanks for your reply, but then i can’t use the default value `print` which is 
the print function Swift provides. Any idea?

Cheers,
Jin

> On 29 Aug. 2016, at 5:44 pm, zh ao  wrote:
> 
> 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..., _ separator: String, _ terminator: String) -> 
> Void = print
> output("Apple", "Banana", ",", "\n”)
> // Error: Missing argument for parameter #2 in call
> 
> Thanks,
> Jin

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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..., _ separator: String, _ terminator: String) -> 
Void = printoutput("Apple", "Banana", ",", "
”)// Error: Missing argument for parameter #2 in call
Thanks,Jin




___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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 2:53 PM +0800, "Jens Alfke"  wrote:











On Aug 28, 2016, at 10:19 PM, Michael Nisi via swift-users 
 wrote:
The 12-hour clock will always remain a mystery to me 
https://en.wikipedia.org/wiki/12-hour_clock

“Likewise, some U.S. style guides recommend either clarifying "midnight" with 
other context clues, such as specifying the two dates between which it falls, 
or not referring to midnight at all. For an example of the latter method, 
"midnight" is replaced with "11:59 p.m." for the end of a day or "12:01 a.m." 
for the start of a day.
Weird; that seems like a useless complication to add.
There’s really no ambiguity about 12:00 AM/PM. AM and PM toggle the instant the 
clock strikes 12. So “12:00 AM” is midnight because the time just flipped from 
PM to AM.
—Jens [a US resident who admits 12-hour time is ungainly, but finds 24-hour 
time cold and soulless]




___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users