Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAaron Williamson
10,421 PointsHow do you decipher and translate the iOS Swift documentation into this class method?
I'm trying to get used to the documentation but it's a stretch to understand. I can find the related information fine, but deciphering what it means has proved tricky for me. For instance, I'm looking at the dataWithContentsOfURL:options:error documentation which states:
Creates and returns a data object containing the data from the location specified by aURL.
- (id)dataWithContentsOfURL:(NSURL )aURL options (NSDataReadingOptions)mask error:(NSError *)errorPtr
Then the result should be according to the video lesson:
NSData.dataWithContentsOfURL(forecastURL, options: nil, error: nil)
My question is how are you supposed to arrive at this result from the documentation? For example, is the (id)
part in the beginning of the example supposed to represent the class NSData
in the result? What does the part :(NSURL *)aURL
mean? Why is NSURL enclosed in it's own parentheses in the example with an asterisk?
I'm just looking for a little guidance in terms of understanding translation from the documentation in order to navigate uncharted waters on my own. Any help is deeply appreciated!
1 Answer
Chris Shaw
26,676 PointsHi Aaron,
What you're looking at is the Objective-C Foundation framework documentation which is why it looks so confusing, instead you want to be referencing the new Cocoa Foundation Reference as it has both Swift and Objective-C documentation side-by-side.
Aaron Williamson
10,421 PointsAaron Williamson
10,421 PointsDurr me, thanks Chris!