Post

Replies

Boosts

Views

Activity

Declaring tuples, or tuple decomposition
The following two statements execute in Swift 5.2.4: let (x, y) = (14, 17) print("x = \(x), y = \(y)") // prints: x = 14, y=17 Yet, the following two statements: let (x: Int, y: Int) = (14, 17) print("x = \(x), y=\(y)") // fails to execute cause a compiler error message on the first line: ! Invalid redeclaration of 'Int' with the "I" of the second Int underlined. Since the first Int type annotation didn't seem to cause any objections, I deleted the second Int to leave this: let (x: Int, y) = (14, 17) print(x, y) That time I get the error message: ! Use of unresolved identifier 'x' All of these lines were parsed in a playground on Xcode 11.6.
3
0
1.3k
Sep ’20
Apple Documentation Icons and their meanings
As a relative newbie to Swift and Xcode, I've been directed to Apple Documentation. When I open the documentation, the left column lists links to various frameworks, services, tools, etc. and each link is prefixed by an icon. The most common icon at the top level is a rounded square enclosing four different colored circles arranged in a square. Clicking on the reveal triangle of the Swift link near the top of that column displays a next level of links, each link prefixed by another icon of three common types: a document icon, an icon showing several lines (code?) and a square containing the letter "S". Entering a search argument typically displays a pop-down menu with several entries, each prefixed by a similar icon. For my purposes, most of these are the letters "S", "C", "E", or "Pr", or the lines icon. I can work out the meaning of some of the more obvious of these icons, such as that S = Structure, C = Class, E = Enumeration and Pr = Protocol but why do I have to work this out? If the purpose of the icons is to help me work my way through the documentation, wouldn't it help to have an explanation easily available to a newbie like me to let me know what all of them are and what each one means? I've done several searches (in Xcode Help, in the documentation, as a Google search) to try to find the answer to that question and have come up empty. A search in this forum for "Apple Documentation icons" is rendered nearly useless because it searches for "document icon" instead. I'm not certain what person or AI decided that "document" meant the same thing as "documentation" but the search was useless for my purposes. Yeah, they're related but "document icon" completely overwhelms the results for my intended search. Can anyone point me to an explanation of these icons? Please don't answer with a helpful explanation of seven or eight of the most common of these icons. I'm looking for an exhaustive list with definitions. If such a list doesn't exist, then why are the icons being used in the first place, as decoration? Thank you in advance for at least reading my diatribe.
4
1
1.1k
Sep ’20