我尝试使用另一个类的调用方法将图片添加到我的NSView。
我如何在secondClass中初始化firstClass实例?
代码示例:
firstClass.m:
//method for adding picture
-(void) createPoint:(NSPoint)location{
point = [NSImage imageNamed:@"point3"];
point.size = NSMakeSize(21, 21);
pView = [[NSImageView alloc] init];
[pView setFrameSize:crimePoint.size];
[pView setImage:crimePoint];
[pView setFrameOrigin:CGPointMake(location.x-10, location.y-10)];
[self addSubview:pView];
}
secondClass.m:
- (IBAction)updateButton:(id)sender {
[firstC createPoint:NSMakePoint(300, 300)]; // FirstClass* firstC; (alloced and inited)
}
这个看起来一样,但我不明白如何使用这个答案:
Calling Method From Another UIViewController Has No Visible Effect