我正在尝试对我的arrayWithCurrentLadder
属性进行延迟实例化,以便我的数组至少被分配和启动一次。但是,似乎我的 setter 从未真正被调用过,因为当我尝试对数组中的对象做任何事情时,什么都没有发生,所以我决定尝试NSLog
使用数组中的一个对象来确定我是否获得了实际值(我在那行代码旁边加了星号,这样你就可以看到了),调试器说(null)
,所以我假设我的设置器实际上没有设置。我在我的设置器中添加了 random NSLog
s 以再次查看,但消息甚至没有出现在调试器中。为什么我的二传手不设置?
#import "LViewController.h"
@interface LViewController ()
@property (nonatomic) BOOL firstLadder;
@property (nonatomic, weak) NSMutableArray *arrayWithCurrentLadder;
@property (weak, nonatomic) IBOutlet UIView *playingView;//connects playingView to LViewController
@end
@implementation LViewController
@synthesize playingView = _playingView;
@synthesize firstLadder = _firstLadder;
@synthesize arrayWithCurrentLadder = _arrayWithCurrentLadder;
-(void)setArrayWithCurrentLadder:(NSMutableArray *)arrayWithCurrentLadder {
if(!_arrayWithCurrentLadder)
_arrayWithCurrentLadder = [NSMutableArray arrayWithCapacity:10];
NSLog(@"kgjfkjg");
_arrayWithCurrentLadder = arrayWithCurrentLadder;
NSLog(@"dkfjdk");
}
- (IBAction)buildLadder:(UIButton *)sender {
if (self.firstLadder) {
*******************************************************************************************
NSLog(@"%@", [[self.arrayWithCurrentLadder lastObject] frame].origin.x);
*******************************************************************************************
if (sender.frame.origin.x == [[self.arrayWithCurrentLadder lastObject] frame].origin.x) {
sender.backgroundColor = [UIColor redColor];
[self.arrayWithCurrentLadder addObject:sender];
}
}
}
- (IBAction)startingLadder:(UIButton *)sender {
if (!self.firstLadder) {
[self.arrayWithCurrentLadder addObject:sender];
}
sender.backgroundColor = [UIColor redColor];
self.firstLadder = YES;
}
@end