Trying to learn from the xml parsing example I can not find documentation on the “.first” in the firstNameNodes.first statement. I have searched the NSXMLNode, NSObject, and NSXMLDocument and element class references. No luck. When typing the code in I get an extensive list of dot items to chose from, but can not locate documentation. Help!
I’m on Chapter 11, and I don’t remember there being an xml parsing example anywhere. There definitely isn’t one in Chapter 1.
Ah, looking in the index for the book, on p. 420 in Chapter 28, there is an xml example. The method nodesForXPath(_:, error:) returns an array, so firstNameNodes is an array, and therefore firstNameNodes.anything will never be documented in NSXMLNode or NSXMLDocument. first is a property of an array. You can get that information by option clicking on first in Xcode. I can’t find any official docs for first, but below is a link to a web page that lists the things you can do to an array in Swift, and it says first is a shorthand(for what, it doesn’t say–maybe firstObject, which is documented in NSArray):
If you press the Option key then click on .first documentation for it will be displayed in a pop-up. There you’ll find that first is actually a variable with a get method which returns the first item in an array or nil if the array is empty. Because it is a variable and not a method, there isn’t anything about it in the documentation.