• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Major Nubie : adding ints get strange values?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Major Nubie : adding ints get strange values?


  • Subject: Re: Major Nubie : adding ints get strange values?
  • From: Charlton Wilbur <email@hidden>
  • Date: Thu, 6 Apr 2006 08:50:47 -0400


On Apr 6, 2006, at 8:24 AM, d2kagw wrote:

im sure its something REALLY simple that i've just missed... but I can't find anything in the net !?

Here:

- ( void ) selectChild:(int *)selectedIndex

you say that selectChild takes a pointer to an integer.

Here:

[self selectChild:( currentIndex + 1 )];

you pass it an integer.

For objects where some compile-time type checking is helpful, you use (SomeClass *) as a type, and pass by reference. For things that aren't objects -- int, long, float, double, bool, char -- you use (int) [or (long), (float), (double) etc.) and pass by value.

You probably want the first message definition to be

	- (void) selectChild: (int) selectedIndex

(You could also fix it by passing a pointer to integer to selectChild every time you invoke it, since the important thing is that you pass what you say you're going to pass, but that's a pretty backwards way to fix it.)

Charlton


-- Charlton Wilbur email@hidden 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
References: 
 >Major Nubie : adding ints get strange values? (From: d2kagw <email@hidden>)

  • Prev by Date: Re: Major Nubie : adding ints get strange values?
  • Next by Date: Check the class of a variable?
  • Previous by thread: Re: Major Nubie : adding ints get strange values?
  • Next by thread: Check the class of a variable?
  • Index(es):
    • Date
    • Thread