Re: Reaching the limits of 'learn by example'
Re: Reaching the limits of 'learn by example'
- Subject: Re: Reaching the limits of 'learn by example'
- From: Cyril Godefroy <email@hidden>
- Date: Sun, 13 May 2001 23:51:58 +0200
Well, in fact, it works.... It's funny how writing things twice makes
you see where your mistakes are. So setting the representedObejct works,
NSLog works, but I need to be more 'precautious' (bad french?) when I
declare my local variables. Apparently Objective-C needs more attention
on that point (didn't seem so).
So this works:
-(void) itemSelected:(id)sender
{
OSStatus err = noErr;
UInt32 count, muteSetting, channel, datasize;
NSString *level = [sender representedObject];
Float32 intLevel=[level intValue];
intLevel = intLevel/6;
NSLog(@"level is :%@",level);
Notice how I declare err and all my UInt32before using NSLog?
Well thanks a lot for your help. Next time I'll double check my code
before.
PS:
Brian Hill just told me I can't do what I did while I was writing those
lines. How come I can't? (And yes, I usually use a so-called object
oriented language where I usually can do that kind of stuff).
On Sunday, May 13, 2001, at 11:36 PM, Stefan Arentz wrote:
On Sun, May 13, 2001 at 11:25:51PM +0200, Cyril Godefroy wrote:
On Sunday, May 13, 2001, at 11:14 PM, Stefan Arentz wrote:
What you get back is the NSMenuItem that was selected. From the menu
item
you request it's 'represented object' or tag value. Both should just
work
so I think there's something wrong with the code that sets up the
menu.
Maybe you can post the relevant code for your docket, I'm sure we can
find out what's causing this.
Stefan
Here are the relevant parts of the code:
Ok. Mini code review :-)
-(void) itemSelected:(id)sender
{
NSString *level = [sender representedObject];
Float32 intLevel=0.1; //testing
//Float32 intLevel = [level intvalue]/6;
This should be intValue. Capital V.
NSLog(@"level is:%@",level);
This doesn't work? What do you see in the console?
Stefan
Cyril Godefroy
www.macosxfr.com
homepage.mac.com/cgodefroy