New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@objc not working as explained. #82
Comments
When using a Swift class on Objective-C with a custom name you should use the same name as in Swift, on runtime the object will be created with the custom name provided, for example:
I think it was added to the style guide just to make more concise with the Objective-C guide. More info: |
I guess it makes sense but it just seems odd as using How does the above help if there's a |
Sorry I didn't understand your question but as an overall what Apple say about specifying name is: "... if the name of your Swift class contains a character that isn’t supported by Objective-C, you can provide an alternative name to use in Objective-C..." So I'm not sure if we should add a custom name, it doesn't seems that was made for that, if you don't add it will generate the object with namespace so you don't risk to have a conflict. |
Ok, my question is:
How does that work? When I do |
I agree with @aaronrogers on this, it caused a great deal of confusion when I initially read the section on Class Prefixes. The way it is written seems to suggest to add the additional name with prefix in the parenthesis, so you could use the class name with prefix in your Objective-C code. However, that's not the case, if one tries to reference the Chicken Swift type with RWTChicken, the code would not compile. The prefixed class name is only used during runtime. Thus, I think the section should be rewritten to be more clear on this. |
Our tutorials are all Swift anyway, so you're right to point out the possible confusion here. |
In the example
@objc (RWTChicken) class Chicken {
The Objective-C header will be created like
So in Objective-C I still have to reference the class as
Chicken
. IsRWTChicken
the intended result?The text was updated successfully, but these errors were encountered: