Swift crash in dispatch_apply
Swift crash in dispatch_apply
- Subject: Swift crash in dispatch_apply
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sat, 05 Jul 2014 13:05:21 +0700
Why does this crash?
class Crash : NSObject // must be subclass of NSObject to get a crash
{
var globalSize = 0
let queue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 )
func makeCrash()
{
globalSize = 97 // anything
let nbrThreads : UInt = 1 // any positive number will do; output might be garbled for > 1
let localSize = globalSize
println("makeCrash will do dispatch_apply( \(nbrThreads) )")
dispatch_apply( nbrThreads, queue,
{ [unowned self] (idx: size_t) in
println( "thread[\(idx)] local \(localSize)") // ok
// next line will crash --- Mac OS X 10.9.4 Xcode Version 6.0 (6A216f)
println( "thread[\(idx)] global \(self.globalSize)") // will crash
}
)
}
}
let dummy = Crash()
dummy.makeCrash()
What am I doing wrong?
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden