PDA

View Full Version : Code to turn flash on?




mikemanblah
Jul 6, 2010, 11:45 AM
What is the code to turn the iphone 4 camera flash on?

Also what does this error mean

error: expected specifier-qualifier-list before '@' token



dejo
Jul 7, 2010, 09:42 AM
Also what does this error mean

error: expected specifier-qualifier-list before '@' token
This usually means you have some kind of syntax error in the code prior to this error. Care to provide some code?

mikemanblah
Jul 7, 2010, 10:48 AM
I dont have anything else written in before it, Its a fresh slate with one line of code

dejo
Jul 7, 2010, 10:54 AM
I dont have anything else written in before it, Its a fresh slate with one line of code
Alright, then. Let's see that one line of code.

mikemanblah
Jul 7, 2010, 04:29 PM
i will in a sec
Anyone got the flash api?

dejo
Jul 7, 2010, 04:31 PM
Anyone got the flash api?
Did you try searching the Developer Documentation for "flash"?

mikemanblah
Jul 7, 2010, 05:08 PM
I'm getting this

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIImagePickerController.h>

@interface Mainview : UIResponder {
UIImagePickerControllerCameraFlashModeOn = 1
(: error: expected specifier-qualifier-list before 'UIImagePickerControllerCameraFlashModeOn')




};
typedef NSInteger UIImagePickerControllerCameraFlashMode;
@end

robbieduncan
Jul 7, 2010, 05:09 PM
You cannot assign values to variables in the @interface section. Only in the @implementation.

dejo
Jul 7, 2010, 05:13 PM
Plus, what the heck is UIImagePickerControllerCameraFlashModeOn?

chown33
Jul 7, 2010, 05:22 PM
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIImagePickerController.h>

@interface Mainview : UIResponder {
UIImagePickerControllerCameraFlashModeOn = 1
(: error: expected specifier-qualifier-list before 'UIImagePickerControllerCameraFlashModeOn')




};
typedef NSInteger UIImagePickerControllerCameraFlashMode;
@end

You need a typename before UIImagePickerControllerCameraFlashModeOn.

If you intend to use UIImagePickerControllerCameraFlashMode as the type of UIImagePickerControllerCameraFlashModeOn, then you need to place it before the typedef is used. C and Objective-C don't support deferred definitions of any types. The typename must be defined before the point of its first use.

Also, the names you're using have already been defined:
http://developer.apple.com/iphone/library/documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/doc/c_ref/UIImagePickerControllerCameraFlashMode

I get the feeling you don't know how to use enum types.

mikemanblah
Jul 7, 2010, 05:32 PM
I'm 13 and i'm just starting out. What would i type instead? Thanks for all the help

dejo
Jul 7, 2010, 05:38 PM
I'm 13 and i'm just starting out. What would i type instead?
I'm gonna suggest instead that it's time to step away from the real coding and go learn the basics of Objective-C.

firewood
Jul 7, 2010, 06:17 PM
I'm gonna suggest instead that it's time to step away from the real coding and go learn the basics of Objective-C.

Or plain C, since that's where Obj C gets its types and type syntax from, plus there are a ton more books available on learning C, probably at your local library for free.

chown33
Jul 7, 2010, 06:27 PM
I'm 13 and i'm just starting out. What would i type instead? Thanks for all the help

No one knows what you'd type instead. You haven't explained what you want to do. No one can write code effectively without knowing what it's expected to do.

In any case, if you have to ask what to type, then you're probably not ready to type any code. You need to do more reading. You can't sit down in the cockpit of a fighter jet and expect to fly it without some training.

We can't read your mind. We can't see your screen. All we know about you and your work is what you tell us in this forum.

If you haven't told us what book or tutorial you're using, then you can't expect advice on a better one. If you're not using a book or tutorial, there are stickies at the top of this forum you should read.

mikemanblah
Jul 7, 2010, 06:35 PM
Well imma go reading up. I was trying to turn the flash on

chown33
Jul 7, 2010, 08:02 PM
Well imma go reading up. I was trying to turn the flash on

Yes, that was obvious. What's not so obvious is the larger context of what you're trying to do.

The UIImagePickerControllerCameraFlashMode type, and its 3 values (off, on, and auto) are used to specify how the flash behaves when taking a picture with the camera. But you asked in another thread about how to turn on the flash LED to use it as "not a flashlight", which is a completely different thing than using it with the camera.
http://forums.macrumors.com/showthread.php?t=962403

So you're still not really explaining what you want to do in a way that someone can give useful suggestions.

Other things that aren't obvious are the extent of your programming experience, and exactly what you're reading that you hope will teach you how to make a flashlight using the LED.

mikemanblah
Jul 7, 2010, 08:08 PM
Just so i can have a test project, whats the iphone documentation page for the led flash that does not require opening of the camera app