RE: where have all the IVARS gone? (long time passing...)
RE: where have all the IVARS gone? (long time passing...)
- Subject: RE: where have all the IVARS gone? (long time passing...)
- From: Vinay Prabhu <email@hidden>
- Date: Mon, 10 Jul 2006 12:19:16 +0530
- Importance: Normal
I am confused,
If I declare any variables under the directive
@interface myClass
@end
Is the scope of iVras are not limited to myClass?
Yes, I am using only one instance of object from myClass.
May be because of this, I haven't noticed the problem... :(
If there are multiple classes declared in the header file.
like,
@interface myClass1
@end
@interface myClass2
@end
In the implementation file if I declare few variables like this,
@interface myClass1 (Private)
int iVar;
@end
@interface myClass2 (Private)
int iVar;
@end
What will be the scope of iVar?
I have tried this, it compiles without any errors!!!
If iVar is global, compiler should have given error for multiple
declaration...
-----Original Message-----
From: Bill Bumgarner [mailto:email@hidden]
Sent: Monday, July 10, 2006 12:08 PM
To: Vinay Prabhu
Cc: 'Rob Ross'; email@hidden
Subject: Re: where have all the IVARS gone? (long time passing...)
On Jul 9, 2006, at 10:53 PM, Vinay Prabhu wrote:
> The '< >' symbols I have used to point the class name,
>
> the actual code looks like this,
>
> @interface myClass (Private)
> //Private variables
> int iVar1;
> float iVar2;
These are now declared as global variables and there will be exactly
one "instance" of each available throughout your entire program.
Instantiate more than one instance of [the incorrectly named]
"myClass" class, and all instances will see the exact same values and
storage location of said variables.
> //Private methods
> - (void)doSomething;
> @end
>
> This works perfectly fine, because I have used the same approach to
> hide the
> private variables in a static library created by me. Where I need to
> expose
> the .h file.
> The static library is up and used in other application without any
> problems.
> Successfully hiding the private variables.
The only way this would "work" is if you are only ever instantiating
exactly one instance of "myClass". In that case, it would appear to
work until you did something like...
iVar1 = 42;
... in any random source file in your application.
b.bum
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s)and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender or email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden