I am working on an iOS SDK 4 project with ARC enabled.
My class MyTextView
(derived from UITextView with UITextViewDelegate
protocol) implements the following static method:
+ (void)showInViewController:(UIViewController*)viewController
{
MyTextView *textEdit = [[MyTextView alloc] init];
textEdit.delegate = textEdit;
[viewController.view addSubview:textEdit];
// Show the keyboard
[textEdit becomeFirstResponder];
}
In one of my view controllers I call the following:
[MyTextView showInViewController:self]
This crashes with warning: Unable to restore previously selected frame.
on becomeFirstResponder
. Looks like some stack related crash because of some cycle. I am fairly new to ARC. The delegate property of UITextView
is defined as assign
(shouldn't ARC interpret that as weak
?). I know this approach is rather strange memory-wise. However, I wanted to know if ARC can handle things like that. Obviously it can't. Any idea what might be the problem and how to solve it?
old post, but here is the answer:
or here aswell