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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:54:49+00:00 2026-06-06T17:54:49+00:00

First of all, sorry for my English… I’m developing an iOS application that has

  • 0

First of all, sorry for my English… I’m developing an iOS application that has an UITabBarController. I want to initialize sockets from this UITabBarController in order to manage any event that occurs inside the application.

The problem is that I don’t know how to do it. With my socket I can send messages to a server and receive them from this server. I would like to receive events if I am in other tab item.

This is my code for creating the socket:

- (void) initNetworkCommunication {

CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"212.227.52.247", 9191,  &readStream, &writeStream);

inputStream = (__bridge NSInputStream *)readStream;
outputStream = (__bridge NSOutputStream *)writeStream;
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open];
[outputStream open];

[self activarUsuario];
}

I have a view for sending messages, but I would like to handle events in all the views I have in my UITabBarController, like WhatsApp she you receive a new message…

Can someone help me, please?

I have been searching in Google for days but I haven’t found anything…

Thank you very much!!

  • 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-06-06T17:54:51+00:00Added an answer on June 6, 2026 at 5:54 pm

    Perhaps you could move your socket communication code to another class, maybe the App Delegate or another singleton type class. Whenever you receive events you could post that information using the default NSNotificationCenter along with a dictionary of data containing the event you received.

    Once you do that you can have each of your UIViewController instances register to receive your notifications using the NSNotificationCenter addObserver:selector:name:object: method. Any time your UIViewController instances receive the notification it will call the method you specified in the selector.

    When you receive an event in your socket code, you can post the notification like this

    [[NSNotificationCenter defaultCenter] postNotificationName:@"MY_NOTIFICATION_TYPE" object:sender userInfo:yourDictionaryOfEventData];

    You can register for the notifications in the UIViewController viewWillAppear: method like so… (if you want to have notifications when view is not visible/loaded you can do this in init)

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedEvent:) name:@"MY_NOTIFICATION_TYPE" object:sender];

    and finally, don’t forget to unregister for the notifications in the viewWillDisappear: of your UIViewController. (or dealloc if you registered for them in init)

    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"MY_NOTIFICATION_TYPE" object:sender];

    NSNotification Apple Docs

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

Sidebar

Related Questions

First of all, I'm sorry for my english. I want to compare two records
First of all sorry for my bad english and Im pretty new in these
First of all, sorry for my English. I need some help with this. Recently
First of all, sorry for my bad English. For my last project on my
first of all, sorry if that question is dumb but I´m a total newbie
First of all i'm sorry for my english... I've a problem getting phone numbers
first of all... i'm italian, so i'm sorry for my bad english! so... this
First of all, I need to say that my English is not good. So
First: sorry for my poor English writing. I remember that in VB6.0 days, we
First of all sorry for my English. I would like to use a backtracking

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.