Re: Major Nubie : adding ints get strange values?
Re: Major Nubie : adding ints get strange values?
- Subject: Re: Major Nubie : adding ints get strange values?
- From: "Clark Cox" <email@hidden>
- Date: Thu, 6 Apr 2006 08:48:14 -0400
On 4/6/06, d2kagw <email@hidden> wrote:
> Hi there,
>
> Apologies for the major newbie question...
> Heres some code from an app im writing, im getting really strange
> data from the variable currentIndex.
> instead of getting 1 or -1, I get 4 or -4, and if I run [self left]
> again, I get 8 and then 12, 16, 20 etc
>
> im sure its something REALLY simple that i've just missed... but I
> can't find anything in the net !?
>
> - ( id ) init
> {
> currentIndex = 0; <-- currentIndex is an int, its declared in the
> header
>
> return self;
> }
>
> - ( void ) selectChild:(int *)selectedIndex
Why is selectedIndex a pointer? I suspect that this is related to your
problem. I imagine that your compiler gave you some warnings about
this that you ignored.
> {
> currentIndex = selectedIndex;
>
> NSLog(@"moving : %i", currentIndex);
> }
>
> - ( void ) left : ( NSNotification * ) notification
> {
> [self selectChild:( currentIndex + 1 )];
> }
>
> - ( void ) right : ( NSNotification * ) notification
> {
> [self selectChild:( currentIndex - 1 )];
> }
>
> thanks a gazillion for your time
--
Clark S. Cox III
email@hidden
My CV/Resume:
http://homepage.mac.com/clarkcox3/files/Resume.pdf
http://homepage.mac.com/clarkcox3/files/Resume.html
_______________________________________________
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