Connect interface builder component to IBOutlet that is a property of a
class outside of any instance of a view controller?
I have a project that is a color picker. For each color component, red,
green, and blue, I have a UIPickerView, a textField, and a stepper. What I
want to do is create a class, let's call it ColorPickerObject that looks
like this
@interface ColorPickerObject : NSObject {
IBOutlet UITextField *colorTextField;
IBOutlet UIStepper *colorStepper;
IBOutlet UIPickerView *colorPicker;
int colorIntegerValue;
NSArray *valuesForComponent1InColorPicker;
NSArray *valuesForComponent2InColorPicker;
NSArray *valuesForComponent3InColorPicker;
}
@property IBOutlet UITextField *colorTextField;
@property IBOutlet UIStepper *colorStepper;
@property IBOutlet UIPickerView *colorPicker;
@property int colorIntegerValue;
@property NSArray *valuesForComponent1InColorPicker;
@property NSArray *valuesForComponent2InColorPicker;
@property NSArray *valuesForComponent3InColorPicker;
@end
Then, I have a colorPickerBrain that looks like this,
#import <Foundation/Foundation.h>
#import "ColorPickerObject.h"
@interface ColorPickerBrain : NSObject {
ColorPickerObject *red,
*green,
*blue;
}
//@property ColorPickerObject *red;
//@property ColorPickerObject *green;
//@property ColorPickerObject *blue;
@end
and for reference my colorPickerViewController, (not sure if this helps or
is relevant to the issue)
#import <UIKit/UIKit.h>
#import "ColorPickerBrain.h"
@interface ColorPickerViewController : UIViewController {
ColorPickerBrain *brain;
}
- (IBAction)redChanged:( id )sender;
- (IBAction)greenChanged:(id)sender;
- (IBAction)blueChanged:(id)sender;
@end
I have all of the UI components laid out on the story board but I am
unsure how to connect them to the outlets defined in the
ColorPickerObject. How can I connect these UIcomponents in my story board
to the outlets defined in ColorPickerObject through the brain instance
created in my view controller that has a red, green, and blue
ColorPickerObject.
I am new to ios, this is technically my first app and I have no idea what
to even look for. Everything I have found talks about connecting
components in a base class that is an instance of a UIView but this base
class isn't view based. I am coming from Java if that helps at all.
No comments:
Post a Comment