Note that there are some explanatory texts on larger screens.

plurals
  1. POSet value of property in main view controller from dynamically instantiated class (objective-c)
    text
    copied!<p>I am totally out of ideas on this... I've tried so many variations that I am dizzy...</p> <p>I have a main UIViewController which, at the touch of a button, adds another UIViewController to one of its subviews. When the dynamic UIVC gets added, a property in the main UIVC is updated to hold a reference to it (called currentObject). This is working fine.</p> <p>The problem I am having is that if I add another dynamic UIVC, the property holding the reference is initially updated correctly, but no matter what I try, I can't get the property to update when I touch the first dynamic UIVC. Everything I try to set "currentObject" from a dynamic UIVC gives me an "unrecognized selector sent to class" error and then bails.</p> <p>I'm holding off from putting code into this post at first. Not sure what I would post that would be helpful.</p> <p>Thanks in advance!</p> <p>Updated:</p> <p>in DynamicModuleViewController.h:</p> <pre><code>@interface DynamicModuleViewController : UIViewController &lt;UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIPopoverControllerDelegate, UIGestureRecognizerDelegate, UITextViewDelegate, UIApplicationDelegate, MFMailComposeViewControllerDelegate&gt;{ DynamicModule *currentObject; } @property(nonatomic, retain) DynamicModule *currentObject; </code></pre> <p>in DynamicModuleViewController.m:</p> <pre><code>@implementation DynamicModuleViewController @synthesize currentObject; -(void)addObject:(id)sender { DynamicModule *dm = [[DynamicModule alloc]init]; // positioning and PanGesture recognition code to allow dragging of module currentObject = dm; [mainView addSubview:currentObject.view]; } @end </code></pre> <p>when added this way, from a button tap, it works fine. </p> <p>Once more DynamicModules are instantiated, I need to update currentObject with the DynamicModule that was tapped last.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload