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 4617264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:05:59+00:00 2026-05-22T02:05:59+00:00

I am facing a problem: I have two view controllers, viewController1 , and viewController2

  • 0

I am facing a problem: I have two view controllers, viewController1, and viewController2.
Here is the method I’m concerned about in viewController1:

-(void)msgToServer:(NSString*)identifier:(NSString *)_username{
    NSString *message = [NSString stringWithFormat:@"%@|%@|<END>", identifier, _username]; 
    CFDataRef messageData = (CFDataRef)[message dataUsingEncoding:NSUTF8StringEncoding];

    CFSocketSendData(s, NULL, messageData, 0);
}

this method is working perfectly in viewController1.

Now I am calling this method from viewController2. I am passing two arguments, identifier and _username. It generates the string perfectly, but when it reaches the last line it misses the value of s — which is a CFSocketRef.
What should I do so that s will retain its value, even if I am in viewController2?

Code from viewController2 which calls the above method:

- (void)viewDidLoad {
    [super viewDidLoad];
    WatchListViewController *watchListViewController = [[WatchListViewController alloc]init];
    [watchListViewController msgToServer:@"PREQ" :userName];
}

Thanks in advance.

  • 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-22T02:06:00+00:00Added an answer on May 22, 2026 at 2:06 am

    Thanx to all who helped me well i solved this problem in this way:
    when I push from viewController1 to viewController2 i am passing two parameters “username” and “s” to viewController2 and then I write this method in viewController2.

    -(void)msgToServer:(NSString*)identifier:(NSString *)_username{
        NSString *message = [NSString stringWithFormat:@"%@|%@|<END>", identifier, _username]; 
        CFDataRef messageData = (CFDataRef)[message dataUsingEncoding:NSUTF8StringEncoding];
    
        CFSocketSendData(s, NULL, messageData, 0);
    }
    

    then I am calling this method in the same view controller and it works perfectly. I think this is the only solution which i find. if any body can make it more efficient then you are welcome. 🙂

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

Sidebar

Related Questions

i am facing one problem in SCSF. I have two workspaces MdiWorkspace DeckWorkspace i
Well, I'm facing a new problem atm. I have two elements fixed to the
I am facing problems in flipping views in iPhone. I have two views in
I have a bean structure to parse JSon files. I am facing one problem,
I am facing this very weird problem, I have created a custom UITableViewCell on
I am facing a problem to submit two forms with one JavaScript function. In
friends, i am facing a problem i have phoneContacts list with name and phone
I am facing the following problem : I have a namespace Exception\* , which
I am facing problem in receiving email. I have a registration form, when form
I am facing a problem with a JavaScript readonly field. I have a textboxes

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.