Note that there are some explanatory texts on larger screens.

plurals
  1. PONSMutableDictionary setObject:forKey - custom class
    primarykey
    data
    text
    <p>I am using this in a UINavigation environment. I have <strong>customClassA</strong>. It inherits <strong>customClassB</strong> and one of its object is a NSMutableDictionary.</p> <p>I alloc and init customClassA in a viewController, then for adding data, I am pushing a new viewController into the stack. The addNewDataViewController sends the newly added data, a <strong>customClassB</strong> object back by its delegate. Everything works fine so far.</p> <p><strong>customClassA</strong> has to store the returned object (<strong>customClassB</strong>) into its NSMutableDictionary object with a key (an NSString created from NSDate).</p> <p>I get "mutating method sent to immutable object" error and can't think of any solution. Any help is appreciated.</p> <p>Thanks.</p> <p>===========================</p> <pre><code>interface customClassA : NSObject { NSDate date; NSArray *array; // will contain only NSString objects } // and the rest as customary ... #import "customClassA.h" interface customClassB : NSObject { NSString *title; NSMutableDictionary *data; // will contain values of customClassA with keys of NSString } // and the rest as customary ... #import "customClassB" #interface firstViewController : UITableViewController &lt;SecondViewControllerDelegate&gt; - (void)viewDidLoad { self.customClassB_Object = [customClassB alloc] init]; // and the rest... } - (void)secondViewControllerDidSaveData:(customClassA *)aData { [self.customClassB_Object.data setObject:aData forKey:[NSString stringWithFormat:@"%@", aData.date]]; // update tableView } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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