Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Hooman Mehr via swift-users
> On Apr 27, 2017, at 7:31 PM, Rick Mann wrote: > > >> On Apr 27, 2017, at 18:56 , Hooman Mehr wrote: >> >> You should be able to type your `dataBuffer ` as [Int8] (Byte array). Then >> you won’t need `withUnsafeMutableBytes`. You can simply call it

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rick Mann via swift-users
> On Apr 27, 2017, at 18:56 , Hooman Mehr wrote: > > You should be able to type your `dataBuffer ` as [Int8] (Byte array). Then > you won’t need `withUnsafeMutableBytes`. You can simply call it like this: > > self.request = c_library_call(, dataBuffer) // Call as if it is a C

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rick Mann via swift-users
So, the dataBuffer has a maximum initial size, then I resize it down to the actual resulting size (the data comes from a sensor and real-world vagaries change the resulting volume of data). Then it eventually gets passed to existing Objective-C++ code, and on to C++ code that wants a void* and

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Hooman Mehr via swift-users
You should be able to type your `dataBuffer ` as [Int8] (Byte array). Then you won’t need `withUnsafeMutableBytes`. You can simply call it like this: self.request = c_library_call(, dataBuffer) // Call as if it is a C array It works because of C interoperability compiler magic. As long as the

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rick Mann via swift-users
> On Apr 27, 2017, at 01:48 , Alex Blewitt wrote: > ... > The let constant may not even be stored in a single place; if it's known to > be constant it can be in-lined at the point of use and potentially unpacked > and dead code elimination throw away the unused members, for

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Mohamed Salah via swift-users
yes I tried self. but it didn’t work as well …. > On Apr 27, 2017, at 9:30 PM, Adrian Zubarev > wrote: > > Have you tried using self.? It’s a good practice to always using self. to > avoid issues where the compiler might use other globally available >

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Adrian Zubarev via swift-users
Have you tried using self.? It’s a good practice to always using self. to avoid issues where the compiler might use other globally available variables/constants functions. --  Adrian Zubarev Sent with Airmail Am 27. April 2017 um 19:28:42, Mohamed Salah via swift-users

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Mohamed Salah via swift-users
Thanks for your support … here you are the piece of code import UIKit class FaceVeiw: UIView { /* it make error to use frame or bounds outside any functions WHY WHY WHY */ let width = frame.size.width // (Gives an ERROR) frame property is not known here let width2 =

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Adrian Zubarev via swift-users
First of all, the swift-user list is mainly for Swift related question, which are not related to other frameworks like UIKit. You might find a better answer at Apple developer forums or on stackoverflow. ;) Second, this question is too general and not easy to answer without any code of yours.

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Saagar Jha via swift-users
Would you mind sharing the code you’re having trouble with? Saagar Jha > On Apr 27, 2017, at 10:22, Mohamed Salah via swift-users > wrote: > > Hi , > > why UIview frame and bounds properties are not seen outside any functions ? > > please advise > > thank you >

[swift-users] UIview frame and bounds properties

2017-04-27 Thread Mohamed Salah via swift-users
Hi , why UIview frame and bounds properties are not seen outside any functions ? please advise thank you Mohamed Salah ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

[swift-users] How to fully strip internal/inline symbols in binaries built with Swift?

2017-04-27 Thread Daniel Alm via swift-users
I need to write some license checking code in Swift. I know Swift is not optimal for that kind of code in the first place, as it is harder to obfuscate and easier to patch than say, pure C. But if the code that needs to know whether the app is registered is written in Swift, this is still better

[swift-users] Swift Package Manager and Linux "availability checks"

2017-04-27 Thread Gwendal Roué via swift-users
Hello, I'm currently working with a fellow githuber on having GRDB.swift, a Swift library around SQLite, run on Linux: https://github.com/groue/GRDB.swift/pull/205 To this end, there is a system package https://github.com/groue/CSQLite.git whose Package.swift specifies that sqlite should be

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rien via swift-users
> On 27 Apr 2017, at 09:54, Rick Mann wrote: > >> >> On Apr 26, 2017, at 23:37 , Rien via swift-users >> wrote: >> >> 1) When you obtain a pointer, it can no longer be ensured by the compiler >> that you won’t write to it. >> 2) A ‘let’

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rick Mann via swift-users
> On Apr 26, 2017, at 23:37 , Rien via swift-users > wrote: > > 1) When you obtain a pointer, it can no longer be ensured by the compiler > that you won’t write to it. > 2) A ‘let’ variable (constant) allows way more optimizations than a ‘var’. I > would not be

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rien via swift-users
1) When you obtain a pointer, it can no longer be ensured by the compiler that you won’t write to it. 2) A ‘let’ variable (constant) allows way more optimizations than a ‘var’. I would not be surprised if the majority of ‘let’ constants never see any memory allocation at all. Regards, Rien

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Florent Bruneau via swift-users
Hi Rick, My understanding on this is that withUnsafePointer() requires an inout argument because it has to take a reference to the variable in order to be able to derive its pointer. The languages requires inout arguments to be vars, leading to withUnsafePointer() requiring the passed object