Well some of you guys have to wait a little longer, but I can already wish
everyone a happy new year from Germany.
--
Adrian Zubarev
Sent with Airmail ___
swift-users mailing list
swift-users@swift.org
Sorry yeah you’re right, the example also requires conditional conformances. If
you do not need dynamic dispatch in your use case then you can workaround the
issue for now by hiding the protocol requirements and abusing the protocol
extension:
import UIKit
protocol AreaProtocol { /* keep it
This is correct. None of your types does conform to your protocol because you
never conformance explicitly.
The extenstion you wrote is just a conditional extension which says if the Self
type conforms to AreaProtocol and the associated typed Element is a CGPoint
then add the area method to
I don’t get your problem here. If you don’t want to debate the correctness of
your code, why are you asking for help or even showing error messages for a
code snippet that cannot work?
1. Drop the access modifier from the extension itself, because this is only for
convenience, which may or may
Hi there,
before filing a new issue I would like to ask if this is intended behaviour or
a bug:
The Foundation class Operation which has it’s roots in Objective-C has a few
readonly properties like the following one:
@available(iOS 2.0, *)
open class Operation : NSObject {
...
open
is a property on Double so it does feel like a bug.
On 1 Sep 2017, at 13:31, Adrian Zubarev via swift-users <swift-users@swift.org>
wrote:
It’s because the compiler does not support this yet. It’s the same with `let
cgColor: CGColor = .clear.cgColor // will not work`.
Instead you need to
It’s because the compiler does not support this yet. It’s the same with `let
cgColor: CGColor = .clear.cgColor // will not work`.
Instead you need to write `UIColor.clear.cgColor` or in your case
`Double.phythagoreanTruple.0`
Am 1. September 2017 um 12:17:57, Rudolf Adamkovič via swift-users
Moving this thread to the correct mailing list.
Am 8. August 2017 um 06:36:18, Félix Cloutier via swift-evolution
(swift-evolut...@swift.org) schrieb:
All this means is that `joined()` does not create an array that contains the
new result. It's only as magic as the COW semantics on arrays.
No it does not have to be a generic enum at all, as long you do not want
extending the types from a diffrent module. Simply add a new enum case for each
type you need, like `case string(String)`. You may also want to ask the wrapped
type for it's hashValue so that it will hash correctly.
--
If the solution you seek is not designed so that the module user can extend the
set of types then you could wrap your types into enum cases and use the enum
for your set. ;) When Swift will support anonymous enum cases, this will be an
elegant solution to these type of things.
--
Adrian
It should be willSet because in the example the job is executed before the new
value is set.
class SomeClass {
var status: Int {
willSet {
guard newValue != self.status { return }
// do something here
}
}
}
--
Adrian Zubarev
Sent with Airmail
Easy: class SomeClass : Equatable {
--
Adrian Zubarev
Sent with Airmail
Am 9. Juli 2017 um 17:11:14, David Baraff via swift-users
(swift-users@swift.org) schrieb:
Given 2-tuples of type (T1, T2), you should be able to invoke the == operator
if you could on both types T1 and T2, right? i.e.
Welcome to the group of people who thinks that the character from Monopoly had
a monocle, including myself. You've just experienced a transdimensional jump
from your universe without even notecing, but where Swift 4 actually had
hashable tuples. :)
Jokes aside, I haven't read anything about it
Plus if you want to play with Swift 4 without running a toolchain or the new
Xcode you can do it in your browser:
https://swift.sandbox.bluemix.net/#/repl
Just change that repl to Swift 4.
--
Adrian Zubarev
Sent with Airmail
Am 1. Juli 2017 um 03:02:38, Adrian Zubarev
The best docs you can get without Xcode I know about is this one here:
https://developer.apple.com/documentation/swift/string
In Swift 4 a String will yet again become a collection type.
--
Adrian Zubarev
Sent with Airmail
Am 1. Juli 2017 um 02:57:05, David Baraff (davidbar...@gmail.com)
Well you’ve mentioned Swift 4 in your original post, therefore I provided a
solution using Swift 4. It’s returning a view called `Substring`.
--
Adrian Zubarev
Sent with Airmail
Am 1. Juli 2017 um 00:38:42, David Baraff (davidbar...@gmail.com) schrieb:
I’m sorry, but I don’t see suffix() as a
let longString = "1234567890"
print(longString.suffix(2)) // prints "90"
--
Adrian Zubarev
Sent with Airmail
Am 30. Juni 2017 um 23:45:01, David Baraff via swift-users
(swift-users@swift.org) schrieb:
I know, I’ve read tons about about this. I sympathize. Unicode, it’s all very
complex.
I myself highly want lazy constants (I’m tired of writing something like file
private private(set) lazy var propertyName: ReferenceType just to hide the
setter from the rest of the codebase), but I don’t think this will ever happen
in Swift, at least not as an improvement for the lazy keyword
Well you are right this is not the right place for such questions, because this
mailing list is about pure Swift topics.
Think about MVC as MVVM where M = M, V = V and C = VM. Don't get confused by
the `Controller` suffix, especially there is no `ViewController` suffix,
because it
Well, I think it’s a step forward by making type(of:) *like* a stdlib function.
Now we need to change .Type and .Protocol syntax to something like Type,
AnyType and also fix the way it behaves in a generic context to finally open
up Type for custom type names. This should also help removing
Furthermore:
In a class declaration, the static keyword has the same effect as marking the
declaration with both the class and final declaration modifiers.
Source.
--
Adrian Zubarev
Sent with Airmail
Am 11. Mai 2017 um 19:07:53, Austin Zheng (austinzh...@gmail.com) schrieb:
`class` and
Have you read closely the bug issue before posting your answer?
--
Adrian Zubarev
Sent with Airmail
Am 11. Mai 2017 um 19:05:13, Zhao Xin (owe...@gmail.com) schrieb:
No. I think it is just a compromise.
Zhaoxin
On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev
I don’t think this is the answer that was asked for. I bet it’s more a
technical question from the internal point of of view.
--
Adrian Zubarev
Sent with Airmail
Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (swift-users@swift.org)
schrieb:
In Swift, you use `static in struct and
Not answering the questions, but sharing a neat trick.
[weak self] in
guard let `self` = self else { return }
self.foo() // strong self :)
--
Adrian Zubarev
Sent with Airmail
Am 1. Mai 2017 um 16:46:33, Rien via swift-users (swift-users@swift.org)
schrieb:
In my code I use a lot of
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
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.
I’m confused, what exactly are you trying to solve? A single view application
without the main Storyboard?
If that’s the case, take a look at my answer here:
http://stackoverflow.com/a/43304755/4572536
Stackoverflow is a better place for such questions. This list is about pure
Swift. ;)
--
R is a non generic type, because the generic part is set to T, that’s why R()
works.
Otherwise you could create typealias Q =
Сarriage and use it like this Q()
--
Adrian Zubarev
Sent with Airmail
Am 4. April 2017 um 19:25:45, Седых Александр via swift-users
(swift-users@swift.org)
Typo, should be instance not istance.
--
Adrian Zubarev
Sent with Airmail
Am 18. Februar 2017 um 12:16:34, Adrian Zubarev
(adrian.zuba...@devandartist.com) schrieb:
You’re welcome. I don’t think there is a better way of doing that. However you
can build some wrappers with some shortcuts.
You’re welcome. I don’t think there is a better way of doing that. However you
can build some wrappers with some shortcuts.
func createInstance(of _: T.Type, _ istance: T) -> T {
return istance
}
let myGreatFunc1 = createInstance(of: Function.self) {
return "\($0) \($1)" //
Not sure what you’re trying to solve there but you could use it like this with
closures:
typealias Function = (Int, Bool) -> String?
let myGreatFunc1: Function = { _ in return nil /* or whatever you need there */
}
let myGreatFunc2: Function = { _ in return nil }
--
Adrian Zubarev
Sent with
If I remember correctly the property on the UIButton is called
`.lineBreakMode`, which accepts an enum.
--
Adrian Zubarev
Sent with Airmail
Am 28. Januar 2017 um 00:46:18, Mutlu Qwerty via swift-users
(swift-users@swift.org(mailto:swift-users@swift.org)) schrieb:
>
>
> How do I make
There is no universal `nil`. `nil` is typed. That said think of `nil` as a
shorthand form for `Optional.none`
--
Adrian Zubarev
Sent with Airmail
Am 23. Januar 2017 um 11:24:18, Седых Александр via swift-users
(swift-users@swift.org(mailto:swift-users@swift.org)) schrieb:
>
> Hello.
> I
to be explicit about what you want to expose
publicly outside of your module.
On Wed, Jan 18, 2017 at 8:40 AM Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
I feel like I’ve seen this discussion somewhere on the mailing list before. If
I remember correctly or it could be o
I feel like I’ve seen this discussion somewhere on the mailing list before. If
I remember correctly or it could be only me, this behavior is by design,
because you don’t want to open your API implicitly to everyone. Internally it
won’t hurt your module, but only allow you to write less code and
Computed properties do not have any default values. That said, you can only use
didSet or willSet on properties like yours to observe them or remove the
default value from the computed property completely to use get and set.
--
Adrian Zubarev
Sent with Airmail
Am 18. Januar 2017 um
= X() as P`. It is in line ` foo(x)`, `x's
type is P`, but `foo(:)` request a parameter type of `A`, not `P`.
`func foo(_ x:A) {}` means, `x` must be `A`, and `A` conforms `P`. But not
all `P`s are `A`.
Zhaoxin
On Fri, Dec 23, 2016 at 5:26 PM, Adrian Zubarev via swift-users
<swift-us
I assume when we get existentials, your problem could be solved like this:
protocol P {}
class X: P {}
func foo(_ x:A) {}
func bar() {
let x = X() as Any
foo(x)
}
Here A will be Any which conforms to P and makes the compiler happy.
let c: P = … here is P and existential like (future)
What are you trying to solve here?
Do you heavily rely on what A can be?
Can’t you just write func foo(_ x: P) {} (here P is an existential like [in
some future] Any)?!
AnyObject is for classes, but you’d get the same result changing X to a class ;)
If you want scratch the surface of what
'.epub' extension is not an iBooks exclusive ;) It's an e-book. Find yourself a
capable reader :)
--
Adrian Zubarev
Sent with Airmail
Am 19. Dezember 2016 um 17:43:22, Steven Harms via swift-users
(swift-users@swift.org(mailto:swift-users@swift.org)) schrieb:
>
> Hi,
>
> I've been
Thanks, that works party as needed but I just realize this main idea here is
exactly an example where one would need generic protocols, because I cannot
overload the function with associatedtype as I’d need it.
--
Adrian Zubarev
Sent with Airmail
Am 2. Dezember 2016 um 13:33:37, Tino Heth
Where is your problem here? It’s simple and easy ;)
extension Integer {
init(_ boolean: Bool) {
self = boolean ? 1 : 0
}
}
Int(10 > 4)
UInt32(1 <= 2)
--
Adrian Zubarev
Sent with Airmail
Am 22. November 2016 um 00:54:47, Rick Mann via swift-users
@swift.org) schrieb:
This is so confusing. "Literals are untyped", but there’s a “BooleanLiteral”,
which is obviously of type Boolean.
-Kenny
> On Nov 21, 2016, at 2:49 AM, Adrian Zubarev via swift-users
> <swift-users@swift.org> wrote:
>
> In general this is
18 Nov 2016, at 13:05, Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
Hi there,
I just can’t get my head around mutable views and COW.
Here is a small example:
final class Storage {
var keys: [String] = []
var values: [Int] = []
}
public struct Document {
only because you used `unowned`. If
you you can grantee it always exists. Just use it directly, this is what
`unowned` for. If you can't grantee that. You should use `weak` and check it
with `if let` or `if foo == nil`
Zhaoxin
On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users
<
, this is what
`unowned` for. If you can't grantee that. You should use `weak` and check it
with `if let` or `if foo == nil`
Zhaoxin
On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
Hi there,
I just can’t get my head around mutable views and
st use it directly, this is what
`unowned` for. If you can't grantee that. You should use `weak` and check it
with `if let` or `if foo == nil`
Zhaoxin
On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
Hi there,
I just can’t get my head around m
nowned` for. If you can't grantee that. You should use `weak` and check it
with `if let` or `if foo == nil`
Zhaoxin
On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
Hi there,
I just can’t get my head around mutable views and COW.
Here is a s
Hi there,
I just can’t get my head around mutable views and COW.
Here is a small example:
final class Storage {
var keys: [String] = []
var values: [Int] = []
}
public struct Document {
var _storageReference: Storage
public init() {
Hi Chris,
thank you for your answer. I can’t wait for property behaviors, it’s going to
be such a powerful feature. :)
--
Adrian Zubarev
Sent with Airmail
Am 1. November 2016 um 18:34:55, Chris Lattner (clatt...@apple.com) schrieb:
On Oct 30, 2016, at 12:50 PM, Adrian Zubarev via swift
Hi there,
is there actually a way to build a custom data structure that will
automatically be converted to little/big endian on a little/big endian system,
just like (U)Int16/32/64 do?
I could build as a workaround a mechanism that will do that for me, but I’m
curious if this is possible with
You could also fallback to http://swiftdoc.org. ;)
--
Adrian Zubarev
Sent with Airmail
Am 12. Oktober 2016 um 17:01:48, Jon Shier via swift-users
(swift-users@swift.org) schrieb:
I’m guessing you only came to Apple’s developer environment with Swift? (If not
I apologize.) The searchability
This is a wrong place to ask. This topic is part of the iOS SDK from Apple not
part of Swift itself or libraries like Foundation.
--
Adrian Zubarev
Sent with Airmail
Am 8. Oktober 2016 um 18:32:50, Lou Zell via swift-users
(swift-users@swift.org(mailto:swift-users@swift.org)) schrieb:
>
>
Maybe :D No actually I had to test an iOS app feature depending on that date
but forget to reset the system date and time.
--
Adrian Zubarev
Sent with Airmail
Am 6. Oktober 2016 um 20:38:53, Vladimir.S (sva...@gmail.com) schrieb:
(Adrian, are you from the future? ;-)
We should move this thread to swift-users.
Here is something that I just tried:
func foo(_: Int, _: Int) {}
func boo(_: (Int, Int)) {}
type(of: foo) == type(of: boo) //=> true ; (((Int, Int)) -> ()).Type
let tuple = (0, 42)
foo(tuple) // Tuple splat was removed => Error
boo(tuple) // Expected
struct B : RawRepresentable {
let rawValue: Int
// init?(rawValue: Int) {
//
// self.rawValue = rawValue
// }
static let c: B = B(rawValue: 0)
static let d: B = B(rawValue: 1)
}
It seems to me that the memberwise initializer init(rawValue: Int) ignores the
Dear Swift community,
currently I’m building a value type XML library which is baked behind the scene
with a reference type to manage graph traversing between nodes. I also like to
COW optimize the xml graph, but I run into one single problem atm.
Image this xml tree:
It’s just a root
I always wanted a way to make some protocol default implementations not
overridable. Now Swift 3 got open vs. public behavior for classes. (Hopefully
the inconsistency will be fixed soon and we’ll get open protocols as well.)
Imagine this scenario with open/public protocols.
// Module A
//
CC to the right place.
--
Adrian Zubarev
Sent with Airmail
Am 20. Juli 2016 um 10:08:13, Fabian Ehrentraud via swift-evolution
(swift-evolut...@swift.org) schrieb:
Hi,
I have a problem with tuple parameter types in a closure. Is this a language
restriction or a bug in the Swift compiler?
memory can’t be
allocated for it.
On Fri, Jun 17, 2016 at 11:38 AM Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
Hello there, I’m trying to optimize my code and reduce copying from different
buffers into a new one.
I thought I just create a Data value with enough capacity
A little bit off-topic: Is there any way to create autocompletion shortcuts in
Xcode that will show only private, internal or both values of an instance?
class Foo {
private var integer: Int = 0
internal var string: String = "foo"
internal func boo() {}
}
let instance = Foo()
Zubarev via swift-users
<swift-users@swift.org> wrote:
I played around with UnsafeMutablePointer and realized one behavior:
let pString = UnsafeMutablePointer.alloc(1)
pString.initialize("test")
pString.predecessor().memory // will crash ax expected
pString.predecessor() == pStri
I’d like to talk about your personal coding styles in swift for its access
control.
Remember these variable names like __magic or _spell or even garbage_?
Sure swift solves the synthesize problem but there might be old habits that let
us write such code.
Here are some examples:
internal
It's also not clear sometimes exactly what "out of bounds" means - for example,
you might have a big chunk of memory representing an array, and then you take a
pointer to only part of that memory, representing a slice of the array. In this
case you can write "out of bounds" of the slice, but
ons or do I miss something here?!
--
Adrian Zubarev
Sent with Airmail
Am 26. Mai 2016 bei 19:14:41, Andrew Trick (atr...@apple.com) schrieb:
On May 26, 2016, at 9:59 AM, Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
I’ve got one more questions about Unsafe(Mutable)Pointe
, Dmitri Gribenko (griboz...@gmail.com) schrieb:
Hi Adrian,
On Sat, May 21, 2016 at 1:48 AM, Adrian Zubarev via swift-users
<swift-users@swift.org> wrote:
> I played around with UnsafeMutablePointer and realized one behavior:
>
> let pString = UnsafeMutable
66 matches
Mail list logo