Stack Exchange
property not found of object of type 'segmentControl' iphone
I have defined segmentControl buttons. 
@property(nonatomic, strong) SegmentControl *option;
SegmentControl *result = [[SegmentControl alloc] initWithFrame:frame items:@[@"Bad", @"Good"]];


result:self.option.selectedSegmentIndex

why am I getting this error: property 'selectedSegmentIndex' not found on object of type 'segmentControl',
@class SegmentControl;
@protocol SegmentControlDelegate <NSObject>
@optional
- (void)segmentControl:(SegmentControl *)segmentControl didSelectSegment:(UIButton *)segment;

@end

@interface SegmentControl : UIView

@property(nonatomic, assign) BOOL staySelected;
@property(nonatomic, weak) id<SegmentControlDelegate> delegate;

- (id)initWithFrame:(CGRect)frame items:(NSArray *)items;

@end


Because the "SegmentControl" class doesn't have a property named "selectedSegmentIndex", perhaps?

yes, what should I use?

What do you mean by "what you should use"?

how can I access the selected segmentControl Button?

Well, would you please show how the SegmentControl class is declared? I cannot possibly have a clue without seeing the relevant part of the code.

I've added it to the question.

Yes, exactly as I thought - you don't declare a property named selectedSegmentIndex. Why do you expect it to be there?

what property I can use based on SegmentControl class defined here?

I don't know what your intention is, but you have to declare and define a property if you want to use it. That's all I can say.

Could it be that you actually wanted to use the stock UISegmentedControl but do not know how to use it?

it was defined as SegmentControl,I was just wondering based on the defined class how I can access its property.

Your class SegmentControl needs to be a subclass of UISegmentControl (not UIView).
