-4
#import <Foundation/Foundation.h>

@interface Person : NSObject
     @property(strong,nonatomic)  NSString *firstName;   
@end
Nirav D
  • 71,513
  • 12
  • 161
  • 183

1 Answers1

0

If you want to access "firstName" in Person.m then simply you can use

self.firstName

And If you want to access it in any other controller then you will have to create object of Person Class and then only you can read or write it's properties. e.g.

Person *person = [[Person alloc] init];
person.firstName = @"Xyz";
NSLog(@"name is->%@", person.firstName);
  • what about `@synthesize` and `_` for same class ? – vaibhav Dec 26 '16 at 07:03
  • self.variable will retain an object for you if you mark the property with retain or strong. _ variable does not address memory management at all.. This is well descibed here.. http://stackoverflow.com/a/10333755/5172413 – Krishna Datt Shukla Dec 26 '16 at 07:12