Instance variables scope in Objective-C -



Instance variables scope in Objective-C -

i suppose default scope ivars @protected.

i declared variable in header file of class:

{ int _test1; }

but print variable _test1 using nslog in totally unrelated object.

nslog(@"%d", _test1);

why _test1 available sec object?

where can find latest ivars scope rules?

thanks in advance.

if talking objective-c v1, correct... unless otherwise defined (by using @public, @private, or @packaged keywords), ivars default @protected.

you're not showing code, can't certain, wonder if have same "issue" described in other post: objective-c - private vs protected vs public

for objective-c 2 kind of "deprecated". article pretty much describes how now: http://robsprogramknowledge.blogspot.com/2011/08/objective-c-property.html

the best place go latest objective-c documentation developer.apple.com... here's link latest programming manual: https://developer.apple.com/library/ios/documentation/cocoa/conceptual/programmingwithobjectivec/introduction/introduction.html

objective-c variables scope instance

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -