Objective-C ++错误:期望的nonqualified-id

时间:2017-03-21 23:50:25

标签: 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。

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

1 个答案:

答案 0 :(得分:2)

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

Look here for info on naming properties