title: Changing Backlight Level, iPhone
body: <p>I searched around for a way to set the backlight level within an app on the iPhone. I found a solution here:</p>
  
  <p><a href="http://www.iphonedevsdk.com/forum/29097-post3.html" rel="nofollow noreferrer">http://www.iphonedevsdk.com/forum/29097-post3.html</a></p>
  
  <p>The problem I have is, when I add this to my app I get an error and a warning. My code is as follows:</p>
  
  <pre><code>#include "GraphicsServices.h"
  
  - (void) viewWillAppear:(BOOL)animated
  {
  
  NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard"));
  previousBacklightLevel = [bl floatValue];
  //Error here : incompatible types in assignment
  
  [bl release];   
  
  GSEventSetBacklightLevel(0.5f);
  // Warning here : implicit declaration of function 'GSEventSetBacklightLevel'
  
  }
  
  //...The rest of my app
  
  - (void)applicationWillTerminate:(UIApplication *)TheNameOfMyAppIsHere
  {
      GSEventSetBacklightLevel(previousBacklightLevel);
  }
  </code></pre>
  
  <p>I am unsure of what is causing this. I also don't really know what needs to be in my .h file here, but I have:</p>
  
  <pre><code>NSNumber *previousBacklightLevel;
  </code></pre>
  
  <p>EDIT// Changed </p>
  
  <pre><code>NSNumber *previousBacklightLevel 
  </code></pre>
  
  <p>to</p>
  
  <pre><code>float previousBacklightLevel;
  </code></pre>
  
  <p>as suggested and this sorted the incompatible types in assignment error.</p>
  
  <p>Now left with:</p>
  
  <p>"_GSEventSetBacklightLevel", referenced from:</p>
  
  <p>-[MyAppViewController viewWillAppear:] in MyAppViewController.o</p>
  
  <p>-[MyAppViewController applicationWillTerminate] in MyAppViewController.o</p>
  
  <p>symbol(s) not found</p>
  
  <p>collect2: ld returned 1 exit status</p>
  
  <p>Not sure how to fix this one either!</p>
  
  <p>Any help would be appreciated,</p>
  
  <p>// EDIT </p>
  
  <p>All problems sorted. Thanks to all who helped me out. I really do appreciate it and can't wait till I can give a little back, by answering some questions.</p>
  
  <p>Many thanks,</p>
  
  <p>Stu</p>