Trying to pass the selection of a SegmentedControl to a variable, but get some difficulties.
my ViewController.h says:
and my ViewController.m says:
I get some warnings and errors, such as " warning: unused variable 'myname_string' " and " error: request for member 'SelectedSegmentIndex' in something not a structure or union ", plus some warnings after the "end" tag about the definition of a method for 'SelectedSegmentIndex'.
Any help?
my ViewController.h says:
Code:
@interface testViewController : UIViewController <UITextFieldDelegate>{
IBOutlet UITextField *myname;
IBOutlet UILabel * actiontodo;
NSString * mystring;
NSString * myindex;
}
....... some properties .......
@property (nonatomic, retain) UITextField *myname;
@property (nonatomic, retain) UILabel *actiontodo;
@property (nonatomic, copy) NSString *mystring;
@property (nonatomic) NSInteger selectedSegmentIndex;
- (IBAction)myaction:(id)sender;
@end
and my ViewController.m says:
Code:
#import "testViewController.h"
@implementation testViewController
@synthesize actiontodo,myname,mystring, myindex;
- (IBAction)myaction:(id)sender {
NSString *myname_string;
indice = self.SelectedSegmentIndex;
if ([myindex] = 0) {
myname_string = @"aaa";
}else{
if ([myindex] = 1) {
myname_string = @"bbb";
}
}
self.mystring = [[NSString alloc] initWithFormat:@"Action required %@!", myname_string];
self.actiontodo.text = self.mystring;
}
I get some warnings and errors, such as " warning: unused variable 'myname_string' " and " error: request for member 'SelectedSegmentIndex' in something not a structure or union ", plus some warnings after the "end" tag about the definition of a method for 'SelectedSegmentIndex'.
Any help?