Ali*_*Ali 283 xcode objective-c automatic-ref-counting
将项目转换为使用ARC时,"切换案例是否在受保护的范围内"是什么意思?我正在转换一个项目使用ARC,使用Xcode 4编辑 - >重构 - >转换为Objective-C ARC ...我得到的一个错误是"切换案例在受保护的范围内"的"部分"交换机开关盒.
编辑,这是代码:
ERROR标记在"默认"情况下:
- (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;
}
Run Code Online (Sandbox Code Playgroud)
Fei*_*anZ 652
每个箱子周围都有支架{}.这应该解决问题(它在我的一个项目中为我做了).
小智 5
对我来说,问题始于开关的中间,并且大括号没有解决,除非你必须在所有之前的case语句中包含{}.对我来说,错误发生在我发表声明时
NSDate *start = [NSDate date];
Run Code Online (Sandbox Code Playgroud)
在前一种情况下.删除之后,所有后续的case语句都从受保护的范围错误消息中清除
| 归档时间: |
|
| 查看次数: |
73820 次 |
| 最近记录: |