Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synthesis of weak property only allowed in arc or gc mode [closed]

Hey i just start ios programming today and i am facing this erro.

plz help me to remove this error

plz suggest me some nice ios developer tutorial

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *txtUsername;
@property (weak, nonatomic) IBOutlet UITextField *txtPassword;
- (IBAction)loginClicked:(id)sender;
- (IBAction)backgroundClick:(id)sender;


@end
like image 902
Nik Avatar asked Mar 01 '13 04:03

Nik


2 Answers

If you're not using ARC, you cannot use weak. For IBOutlet references in non-ARC code, replace your references to weak with retain, instead. (It's a little confusing, but generally you use assign rather than weak in non-ARC code, but for IBOutlet references, you use retain.)

Better yet, as nneonneo suggests, you should use ARC.

like image 179
Rob Avatar answered Oct 12 '22 02:10

Rob


If you're just starting off, you should just enable ARC. It will save you a lot of headaches, and it will resolve that issue.

like image 34
nneonneo Avatar answered Oct 12 '22 02:10

nneonneo