-3

i add 4 text fields in the view and i cant find the way to write it in viewcontroller.h i try this but not work

@interface ViewController : UIViewController

{

UITextField *TextField1 ;
UITextField *TextField2 ;
UITextField *TextField3 ;
UITextField *TextField4 ;
}

then a property doesnt work with me , like this :

{
 @property (weak, nonatomic) IBOutlet UITextField *TextField1 ;
 @property (weak, nonatomic) IBOutlet UITextField *TextField2 ;
 @property (weak, nonatomic) IBOutlet UITextField *TextField3 ;
 @property (weak, nonatomic) IBOutlet UITextField *TextField4 ;
 }

i need some help in that :(

2 Answers2

0

Don't use braces for properties:

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *TextField1 ;
@property (weak, nonatomic) IBOutlet UITextField *TextField2 ;
@property (weak, nonatomic) IBOutlet UITextField *TextField3 ;
@property (weak, nonatomic) IBOutlet UITextField *TextField4 ;

@end

Also, I hope you set up connections for the controls

Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
  • i do that alse but still wrong , there is a yellow mark its said:propert text field requier method , use @syunthesize... – user2350454 Sep 02 '13 at 05:33
  • Then do `@synthesize yourTextField` for each property in `@implementation` part – Andrey Gordeev Sep 02 '13 at 05:35
  • i do that befor a minute ago then appear red mark for each synthesize that sais: existing ivar 'textfield1' for_weak property 'textfield1'must be _weak ... what is that mean ? – user2350454 Sep 02 '13 at 05:49
0

Firstly you should do it like this, the proper way .

@interface ViewController : UIViewController
{
IBOutlet UITextField *TextField1 ;
IBOutlet UITextField *TextField2 ;
IBOutlet UITextField *TextField3 ;
IBOutlet UITextField *TextField4 ;
}
@property (weak, nonatomic) IBOutlet UITextField *TextField1 ;
@property (weak, nonatomic) IBOutlet UITextField *TextField2 ;
@property (weak, nonatomic) IBOutlet UITextField *TextField3 ;
@property (weak, nonatomic) IBOutlet UITextField *TextField4 ;

Well I think you are somewhere unclear about your concepts of the setter and getter methods and declaring simple variables inside an interface.

Please go through the following links :-

Difference between @interface declaration and @property declaration

Declaring IBOutlet inside or outside @interface?

Hope they help your understanding of these concepts more.

Community
  • 1
  • 1
IronManGill
  • 7,222
  • 2
  • 31
  • 52