I have a class with the following set:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
@interface MyViewController : UIViewController
{
NSMutableDictionary *details;
}
@property (nonatomic,retain) NSMutableDictionary *details;
I removed all unnecessary details for this question. In the implementation file I included @synthesize details;
I’m forwarding to this view from another view and in that class I’m getting a local dictionary:
NSMutableDictionary *getData = [responsestring JSONValue];
and I’m setting it to the mutable dictionary in this class, and I tried in two ways. Both of which are mentioned below:
objMyVc.details = [[NSMutableDictionary alloc] initWithDictionary:getData];
objMyVc.details = [getData retain];
Once I am in the MyViewController, the value details is ALWAYS null. Why is this so? Shouldn’t the value be retained in this case?
[EDIT]
I can confirm that getData is not null because I have the following check:
if ([getData valueForKey:@"VALUE"]) {
}
It is within the if statement that I’m trying to assign the value to the details dictionary and forwarding to that ViewController. I also tried to copy like below:
objMyVc.details = getData;
Your code seems correct. Have you checked whether getData is null? I would also check whether details is null immediately after you initialize it. I don’t think that your problem has to do with retaining.