I'm still learning Swift and iOS development but I've been running into this issue and despite my attempts to dig into the weeds a bit I'm still a little confused.
When I start typing true
Xcode 6 suggests the autocompletion TRUE
. Not the end of the world. However, one time I decided to see what would happen if I used TRUE
and the result gave me an error:
'DYLD_BOOL' is not convertible to 'Bool'
Ok, so TRUE is not a Bool... I looked at the file where DYLD_BOOL is defined (it's a struct, by the way) and found the following code:
struct DYLD_BOOL {
init(_ value: UInt32)
var value: UInt32
}
var FALSE: DYLD_BOOL { get }
var TRUE: DYLD_BOOL { get }
Now I'm thoroughly confused; I don't understand what this code is doing. Can someone please shed some light on what is going on here? What is a DYLD_BOOL and when would I use it?
Thanks in advance.
1) you're doing nothing wrong, I experience the same issue with autocompletion : when you try to type 'true', Xcode tries to autocomplete this as 'TRUE' instead of 'true'.
I just filed this as a bug, report number '18945902'
Sometimes you need to solve this by typing 'true' somewhere else, and copy/pasting the text. This is a stupid Xcode bug.
2) the 'DYLD' stuff is some 'DYnamic LoaDer' library, which defines it's own 'Bool' type, with values 'TRUE' and 'FALSE'. This is often done for code compatibility reasons with code coming from other platforms or libraries.
You can really just forget about it, and use 'true' and 'false' for booleans, it should be fixed in the next XCode release as it's an annoying bug.
If you really want to know more about DYLD, here's the doc of the DYLD :-)
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With