Re: int* array going astray
Re: int* array going astray
- Subject: Re: int* array going astray
- From: Luke the Hiesterman <email@hidden>
- Date: Tue, 24 Nov 2009 20:39:28 -0800
This is why some people write if (0 == _state[i]). A mistake there
will definitely generate a compiler error.
Luke
On Nov 24, 2009, at 8:35 PM, James Maxwell wrote:
how do you spell total frustration and stupidity?
how about writing:
if(_state[i] = 0)
when you really mean:
if(_state[i] == 0)
how many hours did I waste trying to find that?..... ugh....
Certainly a simple enough way to make sure a vector isn't retained!
(funny that I didn't get a warning, actually... Is there any build
setting that will protect me from a similar bought of blindness in
the future?)
J.
On 2009-11-24, at 6:40 PM, James Maxwell wrote:
Hey Folks,
Thanks for the responses. I'm doing some testing to specifically
isolate the instance that's giving me the problem, so "self" should
definitely be the right one. There's no persistence stuff written
at all yet, so it can't be initWithCoder. I'm using a totally
vanilla synthesized accessor, without any options (i.e., @property
int* array), but that shouldn't be a problem, should it? And, as I
said, I've got float* arrays/matrices that are created exactly the
same way, and work without problems.
I'll poke around a little bit more, and perhaps try to confirm the
problem in a bogus class. If the problem isn't reproducible there,
then I'll post some code. I just thought maybe someone might have
come up against similar weirdness.
thanks,
J.
(ps - sorry for replying directly to you, Michael. I always forget
that the reply to isn't the list itself!)
On 2009-11-24, at 4:30 PM, Michael Babin wrote:
On Nov 24, 2009, at 6:20 PM, James Maxwell wrote:
I have a couple of int* arrays I'm using as instance variables -
they're declared in my @interface section, and inited using
malloc when I init the object (and free()'d in the dealloc). I
can set them, using standard array notation (i.e., number[i] = 7)
while I'm in a given method, but the values reset to zeros as
soon as I try to read them from another method - that is, they
don't seem to be retained by the object. I really don't get
what's up. I have other 2D float* arrays inited in the same way,
and these work as expected, with their contents being retained by
the class (and thus accessible from other methods). Does anyone
have any explanation as to why this might be happening?
Are you sure that you're looking at the same object in the method
where you set the values vs. the method where you read the values?
That is, is self the same?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden