Git Product home page Git Product logo

Comments (4)

tomlokhorst avatar tomlokhorst commented on May 19, 2024

Since this is all generated code, there's no problem with duplication, so you can definitely do both: Namespacing and merging structs.

This solves the issue for when you have an ambiguous name.
For example, when you have an image and a segue both named "hello", you can do: R.storyboard.Main.hello and R.assets.Main.hello.
And for unambiguous names, you can still use R.Main.goodbye.

However, you can't just leave out hello from R.Main, since that would be very annoying during development. I guess the best would be to create a dummy field of a different type, so a developer immediately knows what the issue is, e.g.: hello: AmbiguousFieldUseStoryboardOrAssets

from r.swift.

tomlokhorst avatar tomlokhorst commented on May 19, 2024

Or, you know, just include the full file name: R.Main.storyboard.hello and R.Main.xcassets.hello
This also scales to directory hierarchies.

from r.swift.

mac-cain13 avatar mac-cain13 commented on May 19, 2024

Hmm, think I like the explicit versions better. You don't want to think you get an UIImage by accessing R.main.hello and accidentally call the string overload, because it's a segue identifier. Let's try that first and optimize towards shorthands if real life development shows that's needed.

from r.swift.

mac-cain13 avatar mac-cain13 commented on May 19, 2024

Just discovered with @tomlokhorst that duplicate image names are a no-go even when in different asset folder. So that makes R.images.[name] possible.

from r.swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.