Objective-C++ Error: Expected unqualified-id

Objective-C++ Error: Expected unqualified-id

最近我检查了我的一个旧应用程序,当我停止使用它时,它仍然运行良好。但是,现在每次我定义 UIImage *new 时,我都会收到错误 Expected unqualified-id

方法如下:

- (void)endTorsoWithUIImageView:(UIImageView *)flipper andError:(NSError *)clothingManagerError {
    currActiveCol.torsoCurrCol = (direction == 1)? currActiveCol.torsoCurrCol + 1 : currActiveCol.torsoCurrCol - 1;
    [clothingManager notifyAboutMovementInSection:ECOSTorso inDirection:(direction == 1)? ECCDNext : ECCDPrevious];

    if (direction == 1) {
        if (currActiveCol.torsoCurrCol + 2 < [[clothingManager.sectionSetSizes objectAtIndex:0] intValue]) {
            flipper = [[sectionMatrix objectAtIndex:0] objectAtIndex:(currActiveCol.torsoCurrCol + 2) % 4];
            [flipper setHidden:YES];
            [flipper setCenter:(direction == 1)?   CGPointMake(self.view.bounds.size.width + self.outfitView.frame.size.width, flipper.center.y) : CGPointMake(0 - self.outfitView.frame.size.width, flipper.center.y)];
            [flipper setHidden:NO];

            ECChangeDirection dir = (direction == 1)? ECCDNext : ECCDPrevious;
            UIImage *new = [clothingManager updateAfterChangeInDirection:dir forSection:ECOSTorso withError:&clothingManagerError];
            if (new != NULL) {
                [flipper setImage:new];
                [flipper setFrame:CGRectMake(flipper.frame.origin.x, flipper.frame.origin.y, flipper.frame.size.width, [self ratifierForImage:new])];
                [self centerImageView:flipper forFocus:ASTorso takingLoctionIntoAccount:NO forLocation:0];
                [[imageAssetCollection objectAtIndex:0] replaceObjectAtIndex:(currActiveCol.torsoCurrCol + 2) % 4
                                                              withObject:new];
            } else {
                // TODO: Report error to google analytics
            }
        }
    } else if (direction == -1) {
        if (currActiveCol.torsoCurrCol - 2 >= 0) {
            flipper = [[sectionMatrix objectAtIndex:0] objectAtIndex:(currActiveCol.torsoCurrCol - 2) % 4];
            [flipper setHidden:YES];
            [flipper setCenter:(direction == 1)? CGPointMake(self.view.bounds.size.width + self.outfitView.frame.size.width, flipper.center.y) : CGPointMake(0 - self.outfitView.frame.size.width, flipper.center.y)];
            [flipper setHidden:NO];

            UIImage *new = (UIImage *)[clothingManager updateAfterChangeInDirection:(direction == 1)? ECCDNext : ECCDPrevious                                                           forSection:ECOSTorso                                                                         withError:&clothingManagerError];
            if (new != NULL) {
                [flipper setImage:new];
                [flipper setFrame:CGRectMake(flipper.frame.origin.x, flipper.frame.origin.y, flipper.frame.size.width, [self ratifierForImage:new])];
                [self centerImageView:flipper forFocus:ASTorso takingLoctionIntoAccount:NO forLocation:0];
                [[imageAssetCollection objectAtIndex:0] replaceObjectAtIndex:(currActiveCol.torsoCurrCol + 2) % 4
                                                              withObject:new];
            } else {
                // TODO: Report error to google analytics
            }
        }
    }
}

方法定义如下- (UIImage * _Nullable)updateAfterChangeInDirection:(ECChangeDirection)direction forSection:(ECOutfitSection)ecos withError:(NSError * _Nullable * _Nullable)error;。该方法本身没有问题,如果不存在图像,则返回特定图像或 NULL。

我真的迷路了,非常感谢任何提示。

不要使用 new 作为开头的变量名。并使用 nil 检查 UIImage,而不是 NULL

Look here for info on naming properties