In order for the member variables of the class to be properly accessed by the external, we need to set the sets and get methods.
[OBJC]View Plaincopy < param name= "wmode" value= "Transparent" >
- @property (nonatomic,retain)nsstring *test1;
- @property (nonatomic,copy)nsstring *test2;
The properties of a member variable are different (retain,copy) relative to the Set method:
[OBJC]View Plaincopy
- @implementation Secondviewcontroller
- -(void) settest1: (nsstring *) test//retain
- {
- //test needs to be retain first, and test is released to nil when self-assignment
- [Test retain];
- if (_test1! = nil) {
- [_test1 release];
- }
- //Direct release No need to judge is also possible, iOS in the release operation of Nil is legal
- //[_test1 release];
- _test1 = test;
- }
- -(void) Settest2: (NSString *) test//copy
- {
- if (_test2! = nil) {
- [_test2 release];
- }
- //can also not be judged
- //[_test2 release];
- _test2 = [test copy];
- }
IOS Set method