Swift forces you to use class name to alert you on the fact that static variables and methods (may) affect the other instances of the class as static variables are shared between instances. That does make sense.
Zhaoxin On Fri, Jul 1, 2016 at 11:57 PM, Jens Alfke <j...@mooseyard.com> wrote: > > On Jun 30, 2016, at 6:47 PM, zh ao via swift-users <swift-users@swift.org> > wrote: > > You should be aware of using static methods as it may change static > variables, which affects all instances of that class. Normally I think > static methods is designed to use outside the class instance, if you have > to use it inside its instance method. You may need to rethink the pattern > you do. > > > This doesn’t make any sense to me. All class-based OO languages have > static/class methods, so this isn’t specific to Swift. And *any* method > can change static class variables. There’s nothing special about static > methods that makes them less suitable for use by instance methods. > > —Jens >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users