Monday, November 19, 2012

To Create the appDelegate variable and Access for Xcode 4.5





AppDelegate.h

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
NSMutableArray *testArray;
}
@property(nonatomic,retain)NSMutableArray *testArray;

AppDelegate.m

@synthesize testArrayName;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
testArrayName = [[NSMutableArray alloc]init];

}


ViewController.h

#import <UIKit/UIKit.h>

@class appDelegate;

@interface ViewController : UIViewController
{
appDelegate *appdelegate;

}

ViewController.m

#import "ViewController.h"

#import “ appDelegate.h”

- (void)viewDidLoad
{
appdelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
}
To access the appdelegate varaable

Ex:

NSString *Desp=[appdelegate.arrayDescList objectAtIndex:appdelegate.objid1];


No comments:

Post a Comment