0

This is really strange. I am getting a CGFloat value from my view and sending it over to my viewController which will pass it along to my audio engine. However, the CGFloat gets modified somehow between the view and viewController. Totally stumped.

Here's the method in the view

-(void)mod:(CGFloat)value
{
    if(value < 0) value = 0.;
        if(value > self.bounds.size.width - 10)value =  self.bounds.size.width - 10.f;

            value =  value / (self.bounds.size.width - 10.f) ;
            NSLog(@"value %g", value);   ///prints a value between 0.0 - 1.0
            [viewController mod:value forVoice:voiceToPlay];
}

that prints a value between 0.0 - 1.0

then in my viewController this method receives it...

-(void)mod:(CGFloat)value forVoice:(NSUInteger)voice
{
    NSLog(@"mod in view control %g", value);

    [audioController mod:value forVoice:voice];
}

and this prints totally wrong numbers such as 1.0842e-19, 2, -2

It's probably something simple, but I can't figure out what it is!! Thanks for your help.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
olynoise
  • 2,016
  • 2
  • 19
  • 32

2 Answers2

0

I'm a beginner, so I'm not sure about this, but can you really change and resend the method's input value to another method? Aren't you supposed to make another CGFloat inside your mod: method and then send that value to viewController?

0

I'm guessing that when you compile this program, you get some warnings (unless you disabled them). Fix them and this will go away.

Specifically, make sure that (a) mod: forVoice: is declared in viewController.h (and that the declaration matches the implementation), and (b) that viewController.h is included in the implementation file for your view before the call.

Stephen Canon
  • 103,815
  • 19
  • 183
  • 269
  • Ok, I was thinking this would be it, but I'm actually getting more errors now. I imported the .h for my viewController (which is actually a subclass of UIViewController), but now the compiler is telling me that it is an "unknown type." – olynoise Dec 16 '11 at 18:47
  • When I include the header for my viewController, it creates errors for most of my other classes, saying they are of "unknown type." I'm wondering if this has to do with some kind of circular reference or something like that. – olynoise Dec 16 '11 at 19:00
  • It's possible; without seeing what the errors are it's hard to say. – Stephen Canon Dec 16 '11 at 20:24