In this tutorial we will see how can we get the IP Address in Iphone.This is the view based apps. Here are some steps for it…
1. Open the xcode & choose "File->New Project".
2. Select "Application" from left menu and then "View-based Application".
3.Name your project as "IpAddress" and save the project.
4.Now just select "5. Now select "IpAddressViewController.h" file from menu for implementation" file from left menu for define a UIImageView. Set the property for UIImageView.
#import <UIKit/UIKit.h>
@interface IpAddressViewController : UIViewController {
IBOutlet UITextView *txt;
}
@end
5. Now select "IpAddressViewController.m" file from menu for implementation
#import "IpAddressViewController.h"
@implementation IpAddressViewController
// 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
txt.text=@"";
}
return self;
}
-(NSString *)getAddress{
char iphone_Ip[255];
strcpy(iphone_Ip,"127.0.0.1");
NSHost *myhost=[NSHost currentHost];
if (myhost)
{
NSString *ad = [myhost address];
if (ad)
strcpy(iphone_Ip,[ad cStringUsingEncoding: NSISOLatin1StringEncoding]);
}
return [NSString stringWithFormat:@"%s",iphone_Ip];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString* address = [self getAddress];
NSString* myIPAdress = [NSString stringWithFormat:@"IP Address: %@", address];
txt.text = myIPAdress;
}
- (void)dealloc {
[super dealloc];
}
@end
6. Now double click on "IpAddressViewController.xib" from Resource folder for open it.
7. On the view window drag the UIImageView from library . Then link the UIImageView to the File's Owner.
8. Then Quit and Save the Interface Builder.
9. Now you are ready for click on "Build & Go" button.
Now you can see the output in iphone simulator .
HHIS I soluhd have thought of that!
4mTkG2 ivtssgngtgbb
5mlOKF , [url=http://eoyjdlpxakca.com/]eoyjdlpxakca[/url], [link=http://lbsvmbvfqvqs.com/]lbsvmbvfqvqs[/link], http://mrgaoemzapch.com/
http://www.shopdiazepamfast.com/ - buy cheap valium online buy generic valium purchase valium 10mg buy cheap valium online http://www.shopdiazepamfast.com/
(4) Responses to this post