Re: [swift-users] Writing a pod catcher for iOS

2017-09-06 Thread Jeff Kelley via swift-users
Incidentally, the book *iOS 10 SDK Development * by Chris Adamson walks you through building a podcast player. If you go to the linked product page, you can even see some livestream captures on Vimeo for free that cover a lot of this material

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

2017-04-27 Thread Jeff Kelley via swift-users
For this you’ll want to use computed properties. let isn’t the right choice since these aren’t constants—they change as the view resizes. Instead, computed properties using var will work: extension UIView { var width: CGFloat { return frame.size.width } } That extension will add a width p

Re: [swift-users] for with optional collection?

2017-02-09 Thread Jeff Kelley via swift-users
You can do something like this: someOptionalCollection?.forEach { item in item.doSomething() } Or this: (someOptionalCollection as? [SomeType])?.forEach { item in item.doSomething() } Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkell

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-23 Thread Jeff Kelley via swift-users
test? If we > can help you by modifying corelibs-xctest itself, that could be another > option here. :) > > - Brian Gesiak > > > On Mon, Nov 21, 2016 at 10:46 AM, Jeff Kelley via swift-users < > swift-users@swift.org> wrote: > >> The type comes from XCTest. I

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-21 Thread Jeff Kelley via swift-users
; | @SlaunchaMan >> <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> >>> On Nov 19, 2016, at 1:58 AM, Jacob Bandes-Storch >> <mailto:jtban...@gmail.com>> wrote: >>> >>> I imagine unsafeBitCast would be the way to go here.

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jeff Kelley via swift-users
://jeffkelley.org/> >> On Nov 19, 2016, at 1:58 AM, Jacob Bandes-Storch > <mailto:jtban...@gmail.com>> wrote: >> >> I imagine unsafeBitCast would be the way to go here. But are you assuming >> that all of the instance methods have type "(Foo) throws -> Void&qu

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jeff Kelley via swift-users
ou assuming > that all of the instance methods have type "(Foo) throws -> Void" ? Or do you > somehow want to dynamically use the type information? > > Jacob > > On Fri, Nov 18, 2016 at 10:37 PM, Jeff Kelley via swift-users > mailto:swift-users@swift.org>&

[swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-18 Thread Jeff Kelley via swift-users
Hello, I’m trying to enumerate the methods of a class in Swift using the Objective-C runtime. Everything is working fine so far, except for the very last step. Suppose I have a Swift class like this: class Foo: SomeSuperclass { @objc func bar() { print("Hello, World!")

Re: [swift-users] Segmentation fault: 11 after updating codebase to Swift 3.0

2016-10-25 Thread Jeff Kelley via swift-users
When I get into these situations, I never find myself using our DTS incidents, but that’s what they’re for. If you have any left, it’s always a good option to look into. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org

Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Jeff Kelley via swift-users
That’s where I would use the ?? operator: let dobString = serverDateFormatter.stringFromDate(dob) ?? "" Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org > On Aug 4, 2016, at 1:32 PM, Daniel Tartaglia via swift-users >

Re: [swift-users] Why does Array subscript fail at runtime?

2016-07-20 Thread Jeff Kelley via swift-users
If I’m not mistaken, the main reason for Swift arrays being unsafe in this way is for performance. Checking each subscript would be expensive in a large loop; it’s much more performant to loop from the array’s start index to its end index. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan

Re: [swift-users] Equality is broken, isn't it?

2016-07-06 Thread Jeff Kelley via swift-users
I wouldn’t expect String and NSString to have identical implementations of hashValue(). Is there a problem you’re having that this example is meant to illustrate? I can see this being an issue if you’re building your own collection type for strings. Jeff Kelley slauncha...@gmail.com | @Slaunc

[swift-users] Where did “powl” go?

2016-07-05 Thread Jeff Kelley via swift-users
Hello all, I’m using Xcode 8.0 and Swift 3 on OS X 10.11, and I’m trying to use powl in an OS X Playground. I see the definition of the pow-related functions in math.h here: extern float powf(float, float); extern double pow(double, double); extern long double powl(long double, long dou

Re: [swift-users] Generic type metadata pattern not found?

2016-06-11 Thread Jeff Kelley via swift-users
Are you installing the internal frameworks themselves via CocoaPods? That was my next step on a previous Swift project and I never got around to it, but it also predates CocoaPods 1.0’s release. My idea was to use the Podfile like so: pod “InternalFramework”, :path=>’.' This gets the dependenc

Re: [swift-users] Swift 3.0 Preview 1 Snapshots available!

2016-06-02 Thread Jeff Kelley via swift-users
r”. > > Ted > >> On Jun 2, 2016, at 7:42 AM, Jeff Kelley via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> Is it just me, or is there no Swift 3 download on that page? I see a 2.2.1 >> release branch download but nothing for 3. >> &g

Re: [swift-users] Swift 3.0 Preview 1 Snapshots available!

2016-06-02 Thread Jeff Kelley via swift-users
Is it just me, or is there no Swift 3 download on that page? I see a 2.2.1 release branch download but nothing for 3. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org On Tue, May 31, 2016 at 5:42 PM, Mishal Shah via swift-users < swift-users@sw

Re: [swift-users] Replacement for NSNumber?

2016-04-11 Thread Jeff Kelley via swift-users
One possible solution is to create an empty Protocol that both Int and Double conform to, perhaps DataValue, and then create your data structure like this: var data: [String: DataValue] Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org

Re: [swift-users] What is [weak self]?

2015-12-14 Thread Jeff Kelley via swift-users
/doc/uid/TP40014097-CH20-ID56> > > Jacob Bandes-Storch > > On Mon, Dec 14, 2015 at 8:50 PM, Jeff Kelley via swift-users > mailto:swift-users@swift.org>> wrote: > Just looking for a technical term here: what is [weak self] at the beginning > of a closure? An

[swift-users] What is [weak self]?

2015-12-14 Thread Jeff Kelley via swift-users
Just looking for a technical term here: what is [weak self] at the beginning of a closure? An annotation? Thanks in advance! Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org