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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:05:35+00:00 2026-06-14T08:05:35+00:00

I want to write an App, that can run two different threads, one for

  • 0

I want to write an App, that can run two different “threads”, one for a Server one for a Client. I have heard, that in Objective-C Dispatch Queues and Blocks are the way to go. I have read the Apple Documentation about Blocks and Dispatch Queues to quite a large extend, however I still fail at the very beginning of my coding.

Am I right, that I need to create 2 Blocks, one for my server code and one for my client code and then put those blocks in the dispatch queue to run concurrently?

I was now trying to create a block for my server, and failed miserably. I tried the following:

#import <Foundation/Foundation.h>

@interface Server : NSObject {
    void (^server)(NSString*, int);
}

@end

And then

 #import "Server.h"

@implementation Server
   server = ^(NSString* host, int port) {
};

@end

I thought I would have to declare the block variable first in a header file, so that I can later refer to it in my ViewController. Any answers about the general structure with some code examples would be highly appreciated 🙂

  • 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-14T08:05:37+00:00Added an answer on June 14, 2026 at 8:05 am

    I would advise creating a typedef, so you can easily create blocks of that type. Like this:

    typedef void (^ServerBlock)(NSString *host, int port);
    

    On your .h:

    ServerBlock myServerBlock;
    

    On your .m:

    myServerBlock = ^(NSString* host, int port) {};
    

    You can put your typedef inside a .h file called constants and then import it on your .pch file (this is just suggestion…)

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

Sidebar

Related Questions

So I want to be able to write an app that can turn on
I need to write a simple app that runs two threads: - thread 1:
I want to write server-side software, to run on Google App Engine (so it
Suppose I want to write an app for Android OS that is not going
I want to write a small Android app with a GUI that should display
I want to write an application that monitors a music player. In my app
I want to write an App that monitors my paired bluetooth connection in the
I've heard that the advantage of java is that people can write code, compile
Possible Duplicate: Detecting SMS incoming and outgoing I want to write a app that
I'm writing an app that's destined for the browser, and I want to write

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.