当将项目转换为使用ARC时,“开关情况在受保护的范围”意味着什么?我正在转换一个项目使用ARC,使用Xcode 4编辑->重构->转换为目标-C.我得到的错误之一是“开关大小写在保护范围内”,在开关箱中的“某些”开关上。
编辑,这是代码:
在“默认”大小写上标记错误:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"";
UITableViewCell *cell ;
switch (tableView.tag) {
case 1:
CellIdentifier = @"CellAuthor";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[prefQueries objectAtIndex:[indexPath row]] valueForKey:@"queryString"];
break;
case 2:
CellIdentifier = @"CellJournal";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[prefJournals objectAtIndex:[indexPath row]] valueForKey:@"name"];
NSData * icon = [[prefJournals objectAtIndex:[indexPath row]] valueForKey:@"icon"];
if (!icon) {
icon = UIImagePNGRepresentation([UIImage imageNamed:@"blank72"]);
}
cell.imageView.image = [UIImage imageWithData:icon];
break;
default:
CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
break;
}
return cell;
}发布于 2011-09-26 23:40:47
用大括号{}包围每个案例本身。这应该解决了这个问题(在我的一个项目中,它确实解决了我的问题)。
发布于 2011-09-26 22:51:54
如果不查看代码,很难确定,但这可能意味着开关内部有一些变量声明,编译器无法判断是否有通向所需的dealloc点的明确路径。
发布于 2014-12-18 07:36:02
解决这个问题有两个简单的方法:
之间。
当要释放变量时,编译器无法计算代码行。导致这个错误。
https://stackoverflow.com/questions/7562199
复制相似问题