这里就是我传递的某些参数的方法,然后,指派的参数值,以本地实例变量和性能的情况下:无法将值分配给实例变量
- (void) assignOwnerView:(UIView*)oView andPosition:(menuPosition)position withTopView:(UIView*)topView {
self.topView = topView;
self.ownerView = oView;
self.position = position;
<< --- other code --- >>
}
这些属性的接口是此(修订版与合成)
@interface MenuVC(){
UIView *ownerView_;
UIView *topView_;
menuPosition position_;
}
@property (nonatomic, retain) UIView *ownerView;
@property (nonatomic, retain) UIView *topView;
@property (assign) menuPosition position;
@end
@implementation MenuVC
@synthesize list, menuDelegate;
@synthesize ownerView = ownerView_;
@synthesize topView = topView_;
@synthesize position = position_;
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{...
枚举在此定义:
typedef enum {
above,
below,
centered
} menuPosition;
AFTE ř执行三个作业,在调试器断点,这些值如下所示:
的接收到的参数值看起来不错,但在实例变量ownerView_
和position_
的所分配的值是不正确的。另一方面,topView
没问题。
当我直接分配给ivars而不是属性时发生同样的事情。
当我升级到Lion(10.7.3)和XCode 4.3.1时,我开始看到这个问题。在那之前它工作正常。我在我的应用中的其他位置看到了这一点,但我还没有看到任何模式。
ARC未被使用。
我之前报告过这个问题,但没有得到答案。在这种情况下,问题描述更简单。这可能会更容易看出问题所在。
更新 - 头文件添加
#import <UIKit/UIKit.h>
@class MenuVC;
@protocol menuDelegateProtocol
typedef enum {
above,
below,
centered
} menuPosition;
- (void) didSelectItemFromMenu:(MenuVC *)menu atIndex:(NSUInteger) index;
@end
@interface MenuVC : UITableViewController {
NSArray *list;
float extendedHeight;
id<menuDelegateProtocol> menuDelegate;
}
@property (nonatomic, retain) NSArray *list;
@property (nonatomic, assign) id<menuDelegateProtocol> menuDelegate;
- (id) initWithFrame:(CGRect)frame style:(UITableViewStyle)style;
- (void) hide;
- (void) unhide;
- (void) assignOwnerView:(UIView*)oView andPosition:(menuPosition)position withTopView:(UIView*)topView;
@end
我们可以看到您的合成语句吗?你的命名选择看起来可能是罪魁祸首。另外,生成调试屏幕的输入示例不会受到伤害。 – 2012-04-16 19:36:36
好的,综合报告现在已经上线了。当我第一次更新时,我必须取消取消。 – Jim 2012-04-16 19:42:20
尝试NSLog()将值排除。调试器可能会感到困惑(开启优化的可能性更大)。 – 2012-04-16 19:59:34