I have a property checkbook using auto synthesize.
if defined in .h inside interface, inside .m, I have to use _checkbook; but if I defined in .m, i have to use checkbook, why?
I have a property checkbook using auto synthesize.
if defined in .h inside interface, inside .m, I have to use _checkbook; but if I defined in .m, i have to use checkbook, why?
A property defined in your .h file is public. A property defined in your .m file is private.
You don't need to declare the property in both files. You choose. If you're only needing to access the property from within your .m file then put it there, else make it a public property and define it in your .h file. The only time you'll need to write @synthesize checkbook = _checkbook;
just inside your opening @implementation YourViewController
block is if you define BOTH a custom getter and setter method for _checkbook
.
//
// YourViewController.m
// Company
//
// Created by First Last on 5/23/14.
// Copyright (c) 2014 Company. All rights reserved.
//
#import "YourViewController.h"
@interface YourViewController ()
@property (strong, nonatomic) UIView *checkbook; // Private
@end
@implementation YourViewController
/*
Your method defs...
*/
- (void)viewDidLoad
{
// Invoke super
[super viewDidLoad];
// Your code
self.checkbook.backgroundColor = [UIColor redColor];
}
@end