When converting a project to use ARC what does “switch case is in protected scope” mean?

前端 未结 8 1297
忘了有多久
忘了有多久 2020-11-29 17:08

When converting a project to use ARC what does \"switch case is in protected scope\" mean? I am converting a project to use ARC, using Xcode 4 Edit -> Refactor -> Convert to

相关标签:
8条回答
  • 2020-11-29 17:52

    Before:

        case 2:
            NSDate *from = [NSDate dateWithTimeIntervalSince1970:1388552400];
            [self refreshContents:from toDate:[NSDate date]];
            break;
    

    I moved NSDate definition before switch, and it fixed the compile problem:

    NSDate *from;  /* <----------- */
    switch (index) {
        ....
        case 2:
            from = [NSDate dateWithTimeIntervalSince1970:1388552400];
            [self refreshContents:from toDate:[NSDate date]];
            break;
    
    }
    
    0 讨论(0)
  • 2020-11-29 17:54
    default:
            CellIdentifier = @"Cell";
            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                ***initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];***
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                }
            break;
        }
    

    Note: Check! The syntax of the bold & italicized line. Rectify it and you are good to go.

    0 讨论(0)
提交回复
热议问题