I have an NSView (we'll call it view1) that is from an NSViewController. The Super view (which we'll call view2) is located inside an NSWindowController. The problem is, I can add view1 to view2, but I can't remove it.
Asked
Active
Viewed 1,110 times
0
-
Why not? What have you tried? – Jun 18 '10 at 23:39
-
`[class.view removeFromSuperView];` and putting a `removeFromSuperView` in the actual view controller class and calling the method from the windowctrler class – Matt S. Jun 19 '10 at 01:55
-
No, the superview either is located within another view, or is the content view of its window. The NSWindowController is not relevant. What does `[class.view superview]` return after `removeFromSuperview`? How are you adding the view to the superview? – Peter Hosey Jun 19 '10 at 05:49
-
null. I'm adding the view by using `[view addSubview:[class.view]];` – Matt S. Jun 19 '10 at 16:28
-
err, make that `[view addSubview:class.view];` – Matt S. Jun 19 '10 at 20:16
1 Answers
2
From your comment I'd guess one of your instance variables to the view controller or the view itself isn't being set correctly, so you're calling removeFromSuperView
on nil. Use the debugger to explicitly see the state of the objects involved.

Marc Charbonneau
- 40,399
- 3
- 75
- 82
-
the view isn't nil before I call `removeFromSuperview` but after I call remove then it is null, but the view itself isn't getting removed – Matt S. Jun 19 '10 at 16:30
-