In swift,is it a global variable or property? -
global variables variables defined outside of function, method, closure, or type context.《the swift programming guide》。
so question:
class dog { var name: string? func run(){ } }
name global variable or property?
@implementation dog{ nsstring *name; - (void)run{ } }
name global variable or property?
since class type, name
property in swift example.
in objective-c example, name
global variable since properties defined in @interface
scope , requires @property
declaration. (instance variables don't require declaration have inside block inside @interface
or @implementation
scopes.)
Comments
Post a Comment