例如,NSString * defaultCellIndentifier = @「HelloWorld」;objective-c何時應該釋放靜態局部變量
什麼時候應該取消分配?字符串是Objective-C中唯一可以變爲靜態的變量嗎?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[BNUtilitiesQuick UtilitiesQuick].currentBusiness=[[BNUtilitiesQuick getBizs] objectAtIndex:[indexPath row]];
//Business * theBiz=[[BNUtilitiesQuick getBizs] objectAtIndex:[indexPath row]];
static NSString * defaultCellIndentifier = @"HelloWorld";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier: defaultCellIndentifier];
//UITableViewCell*cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Hello"] autorelease];;
...
return cell;
}
那麼如果它不是NSString *,但NSDate *看起來像它被取消分配無論如何。只有NSString *可以是靜態的,不是嗎? – 2011-06-05 11:44:00
@Jim Thio:看到編輯,我希望它解釋它。 – DarkDust 2011-06-05 12:01:58