0
[self.lines addObject: [[Line alloc] initWithPosition:CGPointMake([UIScreen mainScreen].bounds.size.width, _currentHeight)]];
for (Line *line in self.lines) {
NSLog(@"d");
}
NSLog(@"k");
...這將顯示K個,但它不會顯示和「d」 S爲什麼不會這個代碼把對象的NSMultableArray
下面是線類的代碼...
//Line.h
#import <Foundation/Foundation.h>
@interface Line : NSObject
@property(assign, nonatomic) int x, y;
- (id)initWithPosition:(CGPoint)pos;
- (void) minusFromX: (int)number;
@end
和其他...
//Line.m
#import "Line.h"
@implementation Line
- (id)initWithPosition:(CGPoint)pos{
self = [self init];
if (self) {
_y = pos.y;
_x = pos.x;
}
return self;
}
-(void)minusFromX: (int)number{
_x -= number;
}
@end
我道歉,因爲這個問題是非常基礎的代碼,但我似乎無法找到一個方法來解決它。感謝您的時間。
您是否創建了'self.lines'實例? – Wain