ARC语义问题“多个方法命名为”setRotation“而只存档 [英] ARC semantic issue "multiple methods named 'setRotation' " while archiving only

查看:296
本文介绍了ARC语义问题“多个方法命名为”setRotation“而只存档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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标签;

in

  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];
}

}


解决方案

将您的cocos2dv3更新为最新版本(目前为RC4)。



我使用Xcode 5.0和cocos2dv3 RC1没问题。
但是更新Xcode到5.1我有这个问题。
因此我将cocos2dv3更新为RC4,现在工作正常。



您可以从此处


My project in cocos2dv3 is throwing ARC Sematic Issue Multiple methods named 'setRotation:' found with mismatched result, parameter type or attributes while archiving(release mode). It runs fine while deploying to simulator/device (debug mode). In release mode compiler gets confused between the implementation of rotation in UIRotationGestureRecognizer and CCNode. When I got the error in CCBAnimationManager.m , I typecasted the object calling the selector setRotation to (CCNode*) but then the error crept up in CCActionInterval. I'm hoping there is a better solution than typecasting everywhere in cocos2d library.

What am i doing wrong? Thankyou for your time.

EDIT

@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;

in

CCAction.m
@synthesize tag = _tag, target = _target, originalTarget = _originalTarget;


-(void) startWithTarget:(id)aTarget
{
    _originalTarget = _target = aTarget;
}

-(void) startWithTarget:(id)aTarget
{
    _originalTarget = _target = aTarget;
}

Class Hierarchy

@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];
   }

}

解决方案

update your cocos2dv3 to latest (RC4 for now).

I was using Xcode 5.0 and cocos2dv3 RC1 with no problem. But updating Xcode to 5.1 I had this problem. So I updated the cocos2dv3 to RC4 and now it's working fine.

You can find cocos 2d latest versions from here.

这篇关于ARC语义问题“多个方法命名为”setRotation“而只存档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆