【发布时间】:2014-04-20 10:49:20
【问题描述】:
我在 cocos2dv3 中的项目抛出 ARC Sematic Issue
发现多个名为“setRotation:”的方法的结果、参数类型或属性不匹配
归档时(发布模式)。它在部署到模拟器/设备(调试模式)时运行良好。
在发布模式下,编译器会混淆 UIRotationGestureRecognizer 和 CCNode 中的轮换实现。
当我在 CCBAnimationManager.m 中遇到错误时,我将调用选择器 setRotation 的对象类型转换为 (CCNode*),但随后错误在 CCActionInterval 中出现。我希望有一个比在 cocos2d 库中到处进行类型转换更好的解决方案。
我做错了什么? 谢谢你的时间。
编辑
@interface CCAction : NSObject <NSCopying> {
id __unsafe_unretained _originalTarget;
id __unsafe_unretained _target;
NSInteger _tag;
}
@property (nonatomic,readonly,unsafe_unretained) id target;
@property (nonatomic,readonly,unsafe_unretained) id originalTarget;
@property (nonatomic,readwrite,assign) NSInteger tag;
在
CCAction.m
@synthesize tag = _tag, target = _target, originalTarget = _originalTarget;
-(void) startWithTarget:(id)aTarget
{
_originalTarget = _target = aTarget;
}
-(void) startWithTarget:(id)aTarget
{
_originalTarget = _target = aTarget;
}
类层次结构
@interface CCActionFiniteTime : CCAction <NSCopying>
@interface CCActionInterval: CCActionFiniteTime <NSCopying>
@interface CCBRotateTo : CCActionInterval <NSCopying>
CCBRotateTo.m {
-(void) startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
startAngle_ = [self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
-(void) update: (CCTime) t
{
[self.target setRotation: startAngle_ + diffAngle_ * t];
}
}
【问题讨论】:
-
在 github 上将其报告为问题。正如您已经指出的,修复只是在弹出此错误的任何地方强制转换为适当的类型(基类)。
-
贴出导致问题的相关代码。
-
@LearnCocos2D 我会的..
-
@rmaddy 编辑了这个问题。但如果我在这里进行类型转换,问题会再次出现在 CCActionInterval
-
显示
target属性是如何声明的。
标签: ios objective-c cocos2d-iphone xcode5