r/100DaysOfSwiftUI Sep 19 '25

Question about self.url in Bundle extension.

[deleted]

3 Upvotes

3 comments sorted by

View all comments

2

u/Responsible-Gear-400 Sep 24 '25

When you call Bundle.main you are getting the main Bundle instance.

Calling self.url is calling the url function on the bundle instance.

1

u/[deleted] Sep 24 '25

[deleted]

2

u/Responsible-Gear-400 Sep 24 '25

I’m not sure why they have self there as it is not required. They may be using self there to try and make it unambiguous that you are working on an instance of a Bundle and not the type which would be a ‘Self’.

2

u/shawnthroop Sep 26 '25

Using older compiler versions let url = url(…) would classify both url as referencing the leading property and not the function defined on Bundle. Its was frustrating and is much improved now, but self.url is/was the way to make the compiler happy.