How to copy an array to appdelegate array and then retrieve it again elsewhere?
<p>I want to store the array of urls in my appdelegate array i.e. <strong>logoArray</strong> from <strong>myMutableArray</strong> and then use it in other viewcontroller, but i am uable to copy as may be i am doing shallow copy, i have tried othes ways also like <strong>initwithArray:copyItems</strong>. </p>

<p>code:-</p>

<pre><code>@class FirstViewController;

@interface AppDelegate_iPhone : NSObject &lt;UIApplicationDelegate&gt; {
    UIWindow *window;

    FirstViewController *viewController;

    NSMutableArray *logoArray;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) NSMutableArray *logoArray;

@end


// NO initialization of logoArra is done in .M file    


@class AppDelegate_iPhone;    
@interface FirstViewController : UIViewController {

    NSMutableArray *array;

    NSString *logoString;
    AppDelegate_iPhone *appDelegate;

}



@end



@implementation FirstViewController


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    int x=5,y=10;

    UIApplication *app = [UIApplication sharedApplication];
    appDelegate=app.delegate;

    NSLog(@" Array ====== %d",[appDelegate.logoArray count]);

    array = [[NSMutableArray alloc]initWithArray:appDelegate.logoArray];

    NSLog(@"array at 0 ===== %@",[array objectAtIndex:0]);


    for (int i=0; i&lt;[array count]; i++) {

        logoString = [array objectAtIndex:i];
        NSLog(@"%@",logoString);
        UIImage *imageFromUrl = [UIImage imageWithContentsOfFile:[NSURL fileURLWithPath:logoString]];



        UIImageView *imgView = [[UIImageView alloc] initWithImage:imageFromUrl];
        [imgView setFrame:CGRectMake(x, y, 196, 90)];
        [self.view addSubview:imgView];


    //  UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapImage)];
    //  [imgView addGestureRecognizer:tgr];
    //  [tgr release];

        //Do the rest of your operations here, don't forget to release the UIImageView
        x = x + 200;
    //  [imgView release];

    }


}





@class Litofinter,AppDelegate_iPhone;

@interface ParsingViewController : NSObject&lt;NSXMLParserDelegate&gt; {

    NSString *myString;
    NSMutableArray *myMutableArray;
    Litofinter *obj;
    NSString *currentElement;

    AppDelegate_iPhone *appDelegate;


}

@property(nonatomic, retain) NSString *myString;
@property(nonatomic, retain) NSArray *myMutableArray;

@end





#import "ParsingViewController.h"
#import "Litofinter.h"
#import "AppDelegate_iPhone.h"


@implementation ParsingViewController

@synthesize myMutableArray, myString;

- (void)parserDidStartDocument:(NSXMLParser *)parser
{
    myMutableArray = [[NSMutableArray alloc]init];

}


// I have parsed here my XML and array gets stored in myMutableArray


- (void)parserDidEndDocument:(NSXMLParser *)parser
{
    UIApplication *app = [UIApplication sharedApplication];
    appDelegate=app.delegate;

    appDelegate.logoArray = [[NSMutableArray alloc]initWithArray:myMutableArray];

//  NSLog(@"appDelegate.logoArray count %d",[appDelegate.logoArray count]);

    for (Litofinter *lito in appDelegate.logoArray) {
        NSLog(@"Array Elements :----- %@",lito.cLogo);
    }
}
</code></pre>
