我对 Objective-C 的内存管理感到困惑。例子:
.h file
@property(nonatomic,retain) NSString *myString;
.m file
@synthesize myString
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [arrayString count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//in this case,i have to check
if(self.myString != nil)
[myString release],self.myString = nil;
//and assign
self.myString = [arrayString objectAtIndex:indexPath.row];
//or i need only assign
self.myString = [arrayString objectAtIndex:indexPath.row];
}
谁能给我解释一下?非常感谢。