Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4626662
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:27:13+00:00 2026-05-22T03:27:13+00:00

I’m making a client-server program for iphone and i want to use my serverIP

  • 0

I’m making a client-server program for iphone and i want to use my serverIP which is a part of my second view in the first view serverIP is a uitextfield. i use to enter the value of ServerIP in second View but i want to use the value of serverIP IN Firstview.

“”secondview.h”” interface file

#import <UIKit/UIKit.h>


@interface secondview : UIViewController {

    IBOutlet UIView *view;
    IBOutlet UITextField *serverIP;
    IBOutlet UITextField *noc;
    IBOutlet UIButton *save;
    IBOutlet UIButton *back;
    IBOutlet UIButton *load;
     IBOutlet UILabel *display1;
}

-(IBAction) back;
-(IBAction) save;
-(IBAction) load;

@property (nonatomic,retain) IBOutlet UITextField *serverIP; 
@property (nonatomic,retain) IBOutlet UITextField *noc;
@property (nonatomic , retain) IBOutlet UILabel *display1;


@end

“”secondview.m”” implementation file

#import "secondview.h"


@implementation secondview


@synthesize serverIP,noc,display1;


-(IBAction) save{

    [[NSUserDefaults standardUserDefaults] setInteger:serverIP forKey:@"save"]; 

    NSUserDefaults *myname = [NSUserDefaults standardUserDefaults];



    [serverIP resignFirstResponder];



}

-(IBAction) load {

    serverIP = [[NSUserDefaults standardUserDefaults] integerForKey:@"load"];

    NSUserDefaults *myname = [NSUserDefaults standardUserDefaults];





}


-(IBAction) back {

    [self.parentViewController dismissModalViewControllerAnimated: YES];
}



- (void)dealloc {
    [super dealloc];
}


@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:27:13+00:00Added an answer on May 22, 2026 at 3:27 am

    Since you have already done this

    [[NSUserDefaults standardUserDefaults] setInteger:serverIP forKey:@"save"];
    

    I will help you on this. First of all, serverIP is an instance of UITextField. If you do as above, you will not be storing the text value held in it. Do this instead –

    [[NSUserDefaults standardUserDefaults] setString:serverIP.text forKey:@"serverIP"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    Now you will be able to access this in the first view. You will have to do this –

    NSString *serverIP = [[NSUserDefaults standardUserDefaults] stringForKey:@"serverIP"];
    

    An Alternate Approach

    However using user defaults might not be the right way. As mentioned above, you can use the application delegate to store all such values which might bloat it up.

    It be better to define a model object (mutable) that can be passed to second view controller from the first. Then you can modify the model object in the second view controller and first view controller should be able to see it.

    I suggest you declare a retained property on the second view controller as NSMutableString *ipAddress which you can modify as [ipAddress setString:serverIP.text];. You will have to declare an iVar in the first view controller and initialize it before passing it along to the second view controller. Let me know if you need additional help on this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.