Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Xcode 6 keep autocompleting true as TRUE from the Dynamic Link Editor library?

Tags:

xcode

ios

swift

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.

like image 847
galois Avatar asked Feb 11 '23 18:02

galois


1 Answers

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

like image 131
Ronny Webers Avatar answered Feb 14 '23 08:02

Ronny Webers