How to retreive Bundle Version in a label from project test-Info.plist in iphone?
Posted
by aman-gupta
on Stack Overflow
See other posts from Stack Overflow
or by aman-gupta
Published on 2010-04-20T13:43:43Z
Indexed on
2010/04/20
14:33 UTC
Read the original article
Hit count: 179
iphone
Hi,
Here I m pasting my codes where i want to retrive Bundle version from my test-Info.plist.
//
// testAppDelegate.h
// test
//
// Created by Fortune1 on 20/04/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import <UIKit/UIKit.h>
@class testViewController;
@interface testAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
testViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet testViewController *viewController;
@end
//////////////
//
// testAppDelegate.m
// test
//
// Created by Fortune1 on 20/04/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "testAppDelegate.h"
#import "testViewController.h"
@implementation testAppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
/////////////////////
//
// testViewController.h
// test
//
// Created by Fortune1 on 20/04/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface testViewController : UIViewController {
UILabel *label;
}
@property(nonatomic,retain) IBOutlet UILabel *label;
@end
///////////////////////
//
// testViewController.m
// test
//
// Created by Fortune1 on 20/04/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "testViewController.h"
@implementation testViewController
@synthesize label;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test-info" ofType:@"plist"];
NSString *versionString = [NSString stringWithFormat:@"v%d", [plistData objectForKey:@"Bundle version"]];
label.text = versionString;
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
But still I got null value where i m wrong please help me out
Thanks in advance
© Stack Overflow or respective owner