Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Svein Halvor Halvorsen via swift-users
var bitfield: UnsafeMutablePointer? bitfield = UnsafeMutablePointer.allocate(capacity: 888) > 23. sep. 2016 kl. 10.47 skrev Gerriet M. Denkmann via swift-users > : > > This used to work in Swift 2.2: > > var bitfield: UnsafeMutablePointer? > bitfield = UnsafeMutablePointer( malloc( 888 ) ) >

Re: [swift-users] @objc and private methods

2016-07-23 Thread Svein Halvor Halvorsen via swift-users
I usually mark my target-action methods like so: private dynamic func didTapNext(sender: UIButton) "dynamic" makes the compiler generate code for dynamic dispatch, that is runtime message passing, like objc. The "private" part doesn't change that, it just reduces clutter. 2016-07-22 15:18 GMT+0

Re: [swift-users] AnySequence and type erasure

2016-06-23 Thread Svein Halvor Halvorsen via swift-users
2016-06-18 10:23 GMT+02:00 Dmitri Gribenko : > On Fri, Jun 17, 2016 at 12:37 PM, Svein Halvor Halvorsen > wrote: > > Ok. Good to hear that I'm not too far off :) > > > > Can you provide me with an example of a sequence type or two that has > some > > map or other function that would benefit from

Re: [swift-users] See documentation comment for discussion

2016-06-18 Thread Svein Halvor Halvorsen via swift-users
let firstLetter = myString.characters.first lør. 18. jun. 2016 kl. 04.38 skrev Brent Royal-Gordon via swift-users < swift-users@swift.org>: > > I've previously used myString[0...1] to get the first character of a > string. > > I'm not sure how, because this has never worked in Swift. Strings use

Re: [swift-users] AnySequence and type erasure

2016-06-17 Thread Svein Halvor Halvorsen via swift-users
i, Jun 17, 2016 at 1:39 AM, Svein Halvor Halvorsen via > swift-users wrote: > > I'm sure people here know about the problem that AnySequence, > AnyGenerator, > > etc solves. > > In Swift, a protocol can have an associated type, which is kinda like > > generics, but

[swift-users] AnySequence and type erasure

2016-06-17 Thread Svein Halvor Halvorsen via swift-users
I'm sure people here know about the problem that AnySequence, AnyGenerator, etc solves. In Swift, a protocol can have an associated type, which is kinda like generics, but you cannot declare a variable like this: let sequence: SequenceType If you want a sequence, any sequence, over ints you need

Re: [swift-users] Unavailable initializers in -Swift.h

2016-06-08 Thread Svein Halvor Halvorsen via swift-users
This is even worse if I want to create a singleton, and ensure that the only way to access it, is through a static let on the class: class Singleton: NSObject { static let instance = Singleton() private override init() { super.init() } } In Swift, I can't instantiate this clas

[swift-users] Unavailable initializers in -Swift.h

2016-06-08 Thread Svein Halvor Halvorsen via swift-users
Hi, In Objective-C, I've often attributed initializer from super classes as unavailable. Like this; @class Dependency; @interface SomeClass : NSObject - (nullable instancetype)init __unavailable; - (nonnull instancetype)initWithDependency:(nonnull Dependency *)dependency; @end This makes the