If that is the case, why should the first 5 work?
The same example as earlier, no block objects associated.
Theoretically it should have exited before anything executes at all.
var count = 0
dispatch_group.notify(queue: .main) {
print("Exited")
}
for i in 0...10 {
dispatch_group.enter()
}
for i in 0...10 {
if i.isMultiple(of: 2) {
count += 1
print(i, "count:", count)
dispatch_group.leave()
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
count += 1
print("MainAsync ", i, "count:", count)
dispatch_group.leave()
}
}
}
The output:
2 count: 2
4 count: 3
6 count: 4
8 count: 5
10 count: 6
Exited
MainAsync 1 count: 7
MainAsync 3 count: 8
MainAsync 5 count: 9
MainAsync 7 count: 10
MainAsync 9 count: 11
Am I missing something?
Post
Replies
Boosts
Views
Activity
var dispatch_group = DispatchGroup()
dispatch_group.notify(queue: .main) {
print("Exited")
}
for i in 0...10 {
dispatch_group.enter()
}
for i in 0...10 {
if i.isMultiple(of: 2) {
print(i)
dispatch_group.leave()
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
print(i)
dispatch_group.leave()
}
}
}
@DTS Engineer Hope this will suffice
@Developer Tools Engineer
Getting this error while trying the workaround.
WARNING: Unable to retrieve complete information for this device. The best available information will be returned. Error: The operation failed because Developer Mode is disabled.
@Developer Tools Engineer
Getting this error while trying the workaround.
WARNING: Unable to retrieve complete information for this device. The best available information will be returned.
Error: The operation failed because Developer Mode is disabled.
UPDATE: Doesn't work with Xcode 16 Beta 4, 16 Beta 5, 16.1 Beta.