c++ - Objective-C++ 错误 : Expected unqualified-id

标签 c++ ios objective-c uiimage objective-c++

最近我检查了我的一个旧应用程序,当我停止使用它时,它仍然运行良好。但是现在每次定义 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 而不是 NULL 检查 UIImage

Look here for info on naming properties

关于c++ - Objective-C++ 错误 : Expected unqualified-id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42940303/

相关文章:

c++ - 如何在 C++ 模板中使用比较表达式?

c++ - 获得通用引用的优势,无需通用引用

objective-c - Emacs、Objective-C 和自动完成

ios - WebView Xcode 7 空白错误

iPhone UIScrollView 如何正确缩放 View ?目前它的高度没有适当调整

c++ - n 个字节的低 7 位串联

c++ - C/C++ 中的字符串化运算符

ios - 同步 AB 地址簿条目

iphone - 从 UIColor 获取重复图案的大小?

ios - iOS 项目 : CVPixelBufferCreate error. 上的 GPUImage