Ah, yes. It is possible to ‘store’ it as a fixed string.
But I would still expect the compiler to treat it as if it were a computed
property.
Given that this is a protocol and a protocol cannot define stored properties.
(yet anyway)
OTOH, what do I know about compilers… lol!
Regards,
Rien
Site:
It cannot be ‘stored’ I would think.
I always compute my implementations.
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - An HTTP(S) web server framework in Swift
> On 08 Sep 2017, at 19:
I was working with very large NSNumber values and noticed some odd behaviour
when converting these values to integers.
An NSNumber with the value +1e+40 will when converted to Ints produce integers
wit the value zero for Int8, UInt8, Int16, UInt16, Int32 and UInt32.
But for Int64 it will produce
> On 23 Jun 2017, at 18:42, Tony Parker via swift-users
> wrote:
>
> Hi all,
>
> This has come up a few times in recent threads, and I wanted to gather some
> additional info on your real world use cases. Just reply to me, and any input
> is appreciated:
>
> 1. Does your JSON use snake_cas
Yes.
But: Only if it makes the code better.
I think that “understandability engineering” is just as important as “software
engineering”. Maybe more so. After all, code that we understand has a better
chance of working correctly than code that follows all paradigms but once the
developer is gon
Dang, hit send too soon. Sorry.
This does not address your question, so please ignore… (foot in mouth)!
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - An HTTP(S) web server framework in Swift
Are you looking for a general purpose JSON interpreter / API ?
There are many of them around, and in fact I do have my own:
https://github.com/Balancingrock/VJson
With VJson I would write:
let json = VJson.parse(… your json object…)
and then access the metadata as:
let buyCount = (json | ”met
I will often use this rule: If a scope need to use ‘self’ at least once, then I
will always use ‘self’ in that scope.
Otherwise I won’t use ’self’ at all.
There are always exceptions though, first and foremost: if the usage of ‘self’
hinders understandability of the code (interferes with self do
I want to generate some HTML code with Swift. Of course there are many way to
do this, but I am not looking to do an "in-dept all options open” approach.
Just some ‘get the html out quickly” type of thing.
So I wonder, how do _you_ do this?
Simply using Strings is one option, but cumbersome and
I’d love to know if there is a better way, but a ‘switch’ or 'if case' is the
only way I know.
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server for websites build in Swift
> On 08
://swiftfire.nl - A server for websites build in Swift
> On 01 May 2017, at 23:26, Guillaume Lessard
> wrote:
>
> Hi Rien,
>
>> On May 1, 2017, at 08:46, Rien via swift-users wrote:
>>
>> In my code I use a lot of queues. And (very often) I will use [weak
> On 01 May 2017, at 17:42, Dennis Weissmann wrote:
>
>>
>> On May 1, 2017, at 5:32 PM, Rien wrote:
>>
>>>
>>> On 01 May 2017, at 16:59, Dennis Weissmann
>>> wrote:
>>>
>>>>
>>>> On May 1, 2017, at 4:4
> On 01 May 2017, at 16:59, Dennis Weissmann wrote:
>
>>
>> On May 1, 2017, at 4:46 PM, Rien via swift-users
>> wrote:
>>
>> In my code I use a lot of queues. And (very often) I will use [weak self] to
>> prevent doing things when ‘self’ is no l
In my code I use a lot of queues. And (very often) I will use [weak self] to
prevent doing things when ‘self’ is no longer available.
Now I am wondering: how does the compiler know that [weak self] is referenced?
I am assuming it keeps a reverse reference from self to the [weak self] in
order t
You will need to take full control over allocation and deallocation.
Here is a piece of code from my project SwifterSockets (on github, see the link
in my signature)
public func tipReceiverLoop(
socket: Int32,
bufferSize: Int,
duration: TimeInterval,
receiver: ReceiverProtocol?)
To address your question:
https://developer.apple.com/reference/foundation/data/1779823-withunsafemutablebytes
"Warning
The byte pointer argument should not be stored and used outside of the lifetime
of the call to the closure."
Which is exactly what you are doing, hence the code is unsafe (no
> 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’ v
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
Sit
Agree, though the function should probably be named something like: withEach
instead of forEach.
Maybe worth a proposal on evolution?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server fo
Because you are (trying) to edit a copy.
To edit the value in the array itself use:
array[index].number += 1
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server for websites build in Swif
With the Array operations: append or insert
var tmp: [CChar] = [0, 0]
for i in 1 ... 100 {
tmp.insert(0, at: 0)
}
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server for websites build
Server-side is usually UTF-8 (not always), so often you don’t really need
strings.
As an aside, time measurements are difficult, especially when IO is involved
there may be thread switches or locks.
I have written some parsers (UTF-8 based) and not yet encountered performance
problems. (though
> On 05 Apr 2017, at 16:26, Maxim Veksler via swift-users
> wrote:
>
> Hi,
>
> Swift 3.1 compiler seems to introduces a new complier warning regarding
> String(describing: )
>
> So this line:
> Log.info("Update name for user \(fbUser)”)
Log.info(“Update name for user \(fbUser ?? “Unknown”)”
I feel your pain ;-)
Just embrace the dark side, it takes a little time to get used to, but chances
are you won’t regret it.
Btw: I still do my development in Xcode, its just that using the SPM (Swift
Package Manager) and git from the command line gives a whole extra dimension to
my productivi
g: http://swiftrien.blogspot.com
>> Github: http://github.com/Balancingrock
>> Project: http://swiftfire.nl
>>
>>
>>
>>
>>
>>> On 24 Mar 2017, at 11:22, Rien via swift-users
>>> wrote:
>>>
>>> IMO this is a boundary problem.
>
Mar 2017, at 11:22, Rien via swift-users wrote:
>
> IMO this is a boundary problem.
> How far do you want to go in letting the compiler deduce the actual type?
> It is possible to make very elaborate constructs that would basically default
> to a complex tuple/array/dictionary construc
IMO this is a boundary problem.
How far do you want to go in letting the compiler deduce the actual type?
It is possible to make very elaborate constructs that would basically default
to a complex tuple/array/dictionary construct with only Any?’s in them. (well,
the dict would require a Hashable
ata() -> Data?
> {
> return nil
> }
>
> guard let data = buildData() else { findReasonAndTerminate() }
>
>
> On Fri, Mar 24, 2017 at 3:02 AM, Rien via swift-users
> wrote:
> Is there any way to mark a function as “no return”?
>
> Reason: The compiler
Is there any way to mark a function as “no return”?
Reason: The compiler generates an error when the else block from a guard does
not terminate the execution by either a return or a fatalError. I want to call
out to a function and raise the fatalError in that function.
func findReasonAndTermina
error: unknown argument: '-debug-time-expression-type-checking'
>>
>> Should I rather compile it on the command line using this option?
>>
>> Regards,
>> Piotr
>>
>> czw., 23 mar 2017 o 08:54 użytkownik Mark Lacey via swift-users
>> napis
ression-type-checking
>
> If you use that you’ll see a line for every expression that is type-checked,
> with source location information, and the time to type check the expression.
> In some cases we may not have valid source information (I believe this
> generally happens for thi
str += "No: \(count), HostIp: " + clientIp + " at port: " + service +
"\n”
Regards,
Rien.
>
> On 23 Mar 2017, at 08:11, Rien via swift-users wrote:
>
>> Thanks for that link, used it to track down the worst compile time offender:
>>
>>
Thanks for that link, used it to track down the worst compile time offender:
This piece of code:
public func logAddrInfoIPAddresses(_ infoPtr: UnsafeMutablePointer)
-> String {
let addrInfoNil: UnsafeMutablePointer? = nil
var count: Int = 0
var info: UnsafeMutablePointer = infoP
> On 11 Mar 2017, at 21:12, Edward Connell via swift-users
> wrote:
>
> Observations about difining an object
> • Structs can't inherit and classes shouldn't inherit, final concrete
> types should be flat
Why?
I always default to the position that we should do what works. Get the project
Ah!, yes that would be perfect!
Many thanks!
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
> On 09 Mar 2017, at 12:36, Ole Begemann wrote:
>
> On 09/03/2017 11:05, Rien via sw
I am trying to achieve the following:
enum FunctionResult {
case success(T)
case error(String)
}
func tester(test: (…) -> FunctionResult, onError: (String) -> T) -> T {
…
}
The problem is of course the (…) that simply does not work.
I would like to use this generic with a variety of diff
I don’t think there is a single answer to this. It is all highly dependant on
what the application does with the info.
Sometimes it will indeed be necessary to rebuild the entire gui, other times it
is enough to simply insert a new table cell.
Regards,
Rien
Site: http://balancingrock.nl
Blog: h
The way I look at it is that Swift wants all symbols resolved when linking.
C++ is probably very lenient toward full resolution, and as long as you know
that a certain unresolved reference is not used, you can safely ignore the
warning.
Or maybe the C++ compiler is just very clever and can figure
Well, that was a bit short…
When you want to use logging, define the ACC “USE_LOGGING” in the build
settings.
When you don’t want to use logging, don’t define the ACC.
PS: You can get my logging framework from github:
https://github.com/Balancingrock/SwifterLog
Regards,
Rien
Site: http://bala
You need conditional compilation.
Called “Active Compilation Conditions” in the build settings.
For example define a ACC of “USE_LOGGING”
Then in your code:
#if USE_LOGGING
import Logging
#else
struct Logging {
func debug(message: string) {}
}
#endif
Regards,
Rien
Site: http://
.
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
> On 18 Feb 2017, at 12:05, Rien via swift-users wrote:
>
> It feels a bit strange to write it like that, but yes, that would work.
gt; let myGreatFunc1: Function = { _ in return nil /* or whatever you need there
> */ }
> let myGreatFunc2: Function = { _ in return nil }
>
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> Am 18. Februar 2017 um 11:47:26, Rien via swift-users (swift-user
with closures:
>>
>> typealias Function = (Int, Bool) -> String?
>>
>> let myGreatFunc1: Function = { _ in return nil /* or whatever you need there
>> */ }
>> let myGreatFunc2: Function = { _ in return nil }
>>
>>
>>
>>
>>
I want to create a few functions that all have the same signature.
The signature is defined in a typealias
Is there any way to shortcut the function definition, or alternatively ensure
that the function signature will always be equal to the typealias?
Examplecode:
typealias Mysig = (Int, Bool)
I don’t know about the candidates
But the uptimeNanoseconds is a UInt64 and as such you should probably use
substractWithOverflow.
var a: UInt64 = 12
var b: UInt64 = 25
let result = UInt64.subtractWithOverflow(a, b)
if result.overflow {
print("Overflow")
} else {
let answer = result.0
> let ptr = UnsafePointer(bitPattern: 123)!
> print(ptr) // 0x007b
>
> // Pointer to Int:
> let int = Int(bitPattern: ptr)
> print(int) // 123
>
> Int has the same size as a pointer on both 32-bit and 64-bit platforms.
>
> Regards, Martin
>
>>
What would be the easiest (and fastest) way to convert a pointer to an
(unsigned)integer?
Ptr -> String -> Int
seems a bit cumbersome to me :-)
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
> On 09 Feb 2017, at 18:29, Cihat Gündüz via swift-evolution
> wrote:
>
> @Jan: Your arguments are very subjective if not even insulting and derogatory
> to many people who invest a lot of time and effort in crafting those things
> you despise so openly. Here are just a few example quotes for
>>>
>>>> And when I use that from another module I get “Operator is not a known
>>>> binary operator”
>>>>
>>>> Once I repeat the "infix operator &=“ at the start of the file it works
>>>> fine.
>>>>
&
tfire.nl
>>
>>
>>
>>
>>
>>> On 03 Feb 2017, at 18:14, Jordan Rose wrote:
>>>
>>> Operator declarations are actually public all the time, not internal.
>>> That’s itself probably a bug, but not the world-limiting one you’re
&
On 03 Feb 2017, at 18:14, Jordan Rose wrote:
>
> Operator declarations are actually public all the time, not internal. That’s
> itself probably a bug, but not the world-limiting one you’re concerned about.
>
> Jordan
>
>
>> On Feb 3, 2017, at 01:18, Rien via swi
I do not think there is a ‘best’ answer.
I would go with JSON though.
Apple’s JSON solution is fast, but it has some minor limitations and usability
is not “up there”.
Then again there are third party solutions, for example my own SwifterJSON
single-class framework that you can download from g
It is possible to define custom operators in a framework, but it is not
possible to assign access levels to them.
As a consequence they are module internal and cannot be used outside the
framework.
Each project needs to redefine the custom operators in order to use them in
that project.
What
I have a system wrapper module/package for openSSL called COpenSsl.
I have another package (called SecureSockets) that uses COpenSsl. This works
fine.
To create a framework, I then added a xcode project to SecureSockets and build
the framework. This also works fine.
Then I created an App (macO
es?
Rien.
>
>> On Jan 26, 2017, at 4:24 AM, Rien via swift-users
>> wrote:
>>
>> Just a quick question,
>>
>>> swift package init —type executable
>>
>> creates an xcode project with a main.swift.
>>
>> I want to create
Just a quick question,
> swift package init —type executable
creates an xcode project with a main.swift.
I want to create a macOS cocoa based application.
How is that best achieved?
Or is that not supported yet?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
G
ave a look at BlueSockets which does the same kind of thing:
>
> https://github.com/IBM-Swift/BlueSocket
> https://github.com/IBM-Swift/BlueSSLService
>
> There's a wrapper around OpenSSL as well:
>
> https://github.com/IBM-Swift/OpenSSL.git
>
> Alex
>
>>
I have created the following packages:
1) SwifterSockets (Swift)
2) COpenSsl (wrapper for system libraries)
3) SecureSockets (Swift, uses SwifterSockets and COpenSsl)
Now I want to build a macOS app that uses SecureSockets.
I have created the app in the traditional way, via Xcode.
In this app I
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
> On 25 Jan 2017, at 19:37, Joe Groff wrote:
>
>
>> On Jan 25, 2017, at 1:23 AM, Rien via swift-users
>> wrote:
>>
>> I have a case where a callback has the following signature:
>>
> On 25 Jan 2017, at 10:33, John Brownie wrote:
>
> Thanks, that does it for me, though I had to qualify the Unmanaged with a
> type in the first part.
>
> Rien wrote:
>> For the context I passed in:
>>
>> UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
>>
>> And to get t
tp://github.com/Balancingrock
Project: http://swiftfire.nl
> On 25 Jan 2017, at 10:23, Rien via swift-users wrote:
>
> I have a case where a callback has the following signature:
>
> @convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer?, _
> arg: UnsafeMutable
I have a case where a callback has the following signature:
@convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer?, _
arg: UnsafeMutableRawPointer?) -> Int32
But to install this callback I have to use a c-function with this signature:
SSL_CTX_callback_ctrl (OpaquePointer!, Int32, (
I am still running into walls with SPM.
Is there a way to specify the header and library search paths when using the
Swift Package Manager?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
_
http://swiftfire.nl
> On 22 Jan 2017, at 06:25, Daniel Dunbar wrote:
>
> What is the glue code you need?
>
> You can define a C/Obj-C target in the same Swift package, and then use it
> from your Swift targets. See:
>
> https://github.com/apple/swift-package-man
Oh, I am not using the correct terminology, sorry. Enum’s don’t have
“instances” right?
Anyhow, I guess you get my drift…
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 21 Jan 2017, at 14:2
The “==“ operation can only compare concrete instances of the enum.
With “type == ACType.other” the right side is not an instance. as the
associated value is missing.
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http
20 Jan 2017, at 19:48, Rien via swift-users wrote:
>
> I may be missing something here, so please bear with me...
>
> The client of the lib only has to see the headers that describe the lib, not
> the headers of the files that were used to create the lib.
> Or are you referri
M myself I don’t know if there are any public plans to do so.)
>
> The recommended solution is to group your Objective-C headers into modules
> (usually just frameworks) and import them that way, rather than to jam them
> in via a bridging header.
>
> Sorry for the troub
I noticed something strange about Xcode and SPM concerning the capability to
generate Libraries.
When I try to create a Library in Xcode and then want to add an Objective-C
bridging header, that is denied. It claims that bridging is not supported for
Libraries.
When I create an Xcode project t
cases from each other.
>
> Slava
>
>> On Jan 10, 2017, at 9:52 AM, Rien via swift-users
>> wrote:
>>
>> I stand corrected.
>>
>> I do/did think that there is a difference in the way it handles pointers
>> optionals and other optionals, but I now re
I have a small sockets based framework on Github (SwifterSockets).
It was created before SPM existed.
The next update is planned, and I want to move to SPM.
1) How to create a package around the old xcode project?
2) I am unsure how to move from the old git structure to the new.
What would be the
://github.com/Swiftrien
Project: http://swiftfire.nl
> On 11 Jan 2017, at 10:28, Rien via swift-users wrote:
>
> My project uses openSSL and that works fine.
>
> I needed one specific function that cannot be accessed from Swift directly,
> so I created a C-file for that. (both .h and
My project uses openSSL and that works fine.
I needed one specific function that cannot be accessed from Swift directly, so
I created a C-file for that. (both .h and .c file)
The function is found during compilation.
But is then reported as “unused” and the linker reports “missing function”.
A
://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 10 Jan 2017, at 18:14, Joe Groff wrote:
>
>
>> On Jan 9, 2017, at 11:19 PM, Rien via swift-users
>> wrote:
>>
>> It means that a call to th
It means that a call to that function with an optional will unwrap the optional
before it is used.
That is quite neat when dealing with C-API’s because often you will receive a
pointer from a C-function which is optional to account for the fact that it can
be NULL (= nil).
By using a forced unw
Thanks Rod, very enlightening!
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 06 Jan 2017, at 15:19, Rod Brown wrote:
>
>
>> On 7 Jan 2017, at 12:50 am, Rien wrote:
>>
>> Hmm, that is i
Hmm, that is interesting to know. I had not realised that URL is in fact NOT a
NSURL but a new type that is based on NSURL (and can be toll-free bridged I
assume?).
I also presume that the same is true for Data/NSData, Date/NSDate etc?
(Failure on my part, as I did of course know that the .path
URL is the same as NSURL in Swift 3
Foundation -> NSURL -> getResourceValue.
If you use xcode, open up the Help -> Documentation and API reference
The do a search for getResourceValue.
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swif
What is your real question?
Obviously the doc says that this is fine, so what are you asking? what is your
problem?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 05 Jan 2017, at 20:36, J.E
As you know. there is no ambiguity, no warnings needed.
(The parameter is part of the identifier of the function)
Imo, this request falls into the category “do as I think, not as I say”.
That is a discussion without end. Personally I am against ANY warnings of this
kind. The reason is that I wan
Thanks Jeremy & Ole,
That was indeed my expectation, but I had not thought of looking in the source
code!
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 03 Jan 2017, at 16:31, Ole Begemann
The documentation at
https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html
shows that it is possible to use String where an UnsafePointer is needed.
API calls to C that need a char* are translated to UnsafePointer.
It follows that w
> >> it, so it’s certainly known behavior, if not desired. IMO it’s a bug and
> >> `:` should be fixed to include the root type, whether or not that requires
> >> a discussion on -evolution.
> >>
> >>> On Dec 22, 2016, at 2:17 PM, Howard Lovatt via swift-u
not desired. IMO it’s a bug and `:`
>> should be fixed to include the root type, whether or not that requires a
>> discussion on -evolution.
>>
>>> On Dec 22, 2016, at 2:17 PM, Howard Lovatt via swift-users
>>> wrote:
>>>
>>> I suspect a
Ah, ok.
In that case, I believe it is correct because sockaddr_storage is in fact big
enough to hold either the IPv4 or IPv6 structure.
When bits go unused, that causes no harm. And when “addr” goes out of scope, it
will be completely deallocated, so no memory leak either.
Regards,
Rien
Site:
I used the code from
http://blog.obdev.at/representing-socket-addresses-in-swift-using-enums/ in my
package SwifterSockets (see github link below)
It does not answer your question exactly, but I think it is a rather better
approach to sockaddr usage.
Regards,
Rien
Site: http://balancingrock.n
As to the why question: (just guessing here)
By the time the compiler want to know what type will be in the array, it cannot
do so. The enum is a generic and thus without full type information (it only
has partial type information).
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swif
I think you made your type (enum) unnecessary complex, the following works:
protocol Element {
}
enum ElementNode {
case element(Element)
case empty
}
var childElements = [ElementNode]()
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http:
Nattinger wrote:
>>> I recall seeing a request on the -evolution list for something like `T :=
>>> X` to indicate it could be X itself or anything inheriting / implementing
>>> it, so it’s certainly known behavior, if not desired. IMO it’s a bug and
>>> `:`
a
>> discussion on -evolution.
>>
>>> On Dec 22, 2016, at 2:17 PM, Howard Lovatt via swift-users
>>> wrote:
>>>
>>> I suspect a compiler bug since A is a P. The equivalent in Java works:
>>>
>>> interface P {}
>>> c
IMO the error message says it all:
Playground execution failed: error: MyPlayground8.playground:9:5: error: cannot
invoke 'foo' with an argument list of type '(P)'
foo(x)
^
MyPlayground8.playground:9:5: note: expected an argument list of type '(A)'
foo(x)
^
I.e. you are passing
>
>> What is the type of self? If it is a class, try [unowned self].
>>
>> Zhaoxin
>>
>>
>>
>>
>>
>>
>> On Fri, Dec 16, 2016 at 4:33 PM, Rien via swift-users
>> wrote:
>> How about using:
>>
>>
How about using:
UnsafeMutablePointer
?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 16 Dec 2016, at 09:10, Richard Wei via swift-users
> wrote:
>
> Capturing makes it immutable, whic
I seem to remember that while it is possible to define, the compiler will yield
an error if you try to use the functions (“cannot resolve”).
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 1
The manual says this:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html
A defer statement is used for executing code just before transferring program
control outside of the scope that the defer statement appears in.
The scope o
As usual: it depends.
I use enums with associated values quite a lot.
In my experience there is quite a thin line between very convenient and too
much.
I have several cases where I started off with enums with associated values,
only to later convert them to classes.
As long as the enums only hav
> On 04 Nov 2016, at 17:48, Ryan Lovelett wrote:
>
>> I often end up “printing” the addresses or using GDB to take an inside
>> look.
>
> That is a really simple interrogation technique I wish I had thought of
> that! Thank you!
>
>> One thing that tripped me up: if you use inout variables, th
> On 04 Nov 2016, at 13:59, Ryan Lovelett via swift-users
> wrote:
>
> struct Foo {
> init(from buffer: Data) {
> bar = integer(withBytes: Array(buffer[4..<6]))
> baz = integer(withBytes: Array(buffer[6..<8]))
> ...
> }
>
> let d = Data(count: Int(3e+8))
> let f = Foo(from: d)
>
> On 03 Nov 2016, at 23:58, Manfred Schubert via swift-users
> wrote:
>
> Am 03.11.2016 um 15:41 schrieb Rien :
>>
>> Ah, but that is not the case.
>>
>> It is important to differentiate between the “gateway” to the memory and the
>> memory area itself.
>> Different programming languages/com
http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl
> On 04 Nov 2016, at 06:24, Andrew Trick wrote:
>
>>
>> On Nov 3, 2016, at 7:41 AM, Rien via swift-users
>> wrote:
>>
>>> On 03 Nov 2016, at 15:16,
1 - 100 of 107 matches
Mail list logo