Skip to content
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

The NS prefix should only be used by Apple #57

Open
seanlilmateus opened this issue May 21, 2020 · 4 comments
Open

The NS prefix should only be used by Apple #57

seanlilmateus opened this issue May 21, 2020 · 4 comments

Comments

@seanlilmateus
Copy link

seanlilmateus commented May 21, 2020

according to the Apple's docs the NS and UI prefixes are exclusively for Apple classes,
otherwise your own classes could collide with future apple's classes

In order to keep class names unique, the convention is to use prefixes on all classes. You’ll have noticed that Cocoa and Cocoa Touch class names typically start either with NS or UI. Two-letter prefixes like these are reserved by Apple for use in framework classes. As you learn more about Cocoa and Cocoa Touch, you’ll encounter a variety of other prefixes that relate to specific frameworks:
[..]
Your own classes should use three letter prefixes.

e.g.:
NSTracingErrorView
NSSimpleModuleBaseView
UIStateManager

You Actually don't need class prefixes in Swift

Create a Swift class for your corresponding Objective-C .m and .h files by choosing File > New > File > (iOS, watchOS, tvOS, or macOS) > Source > Swift File. You can use the same or a different name than your Objective-C class. Class prefixes are optional in Swift.

Solution:

You could either create your own Prefix (following the Objective-C Prefix convention) or remove it completely

Why This should be fixed
At the moment users might imply that those classes are coming from Apple, and look for its documentation on Apple's doc page

@maerki
Copy link
Contributor

maerki commented May 21, 2020

It true, that was a bit of an unfortunate decision that happened that happened in one of the late nights eary in the project.

We might fix this somewhen, but security, stability and UX are more important right now. Would you be interested to start a PR?

@seanlilmateus
Copy link
Author

Alright, I will remove the prefixes and create a PR

@maerki
Copy link
Contributor

maerki commented May 22, 2020

Great. A few remarks:

@maerki maerki linked a pull request May 26, 2020 that will close this issue
@UBaggeler
Copy link
Contributor

As the code base is not changing much anymore, are you still interested in updating the pull-request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants