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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:23:55+00:00 2026-05-16T02:23:55+00:00

NSStreamDelegate was defined in previous OS as (NSObject)NSStreamDelegate In the latest OS it is

  • 0

NSStreamDelegate was defined in previous OS as (NSObject)NSStreamDelegate
In the latest OS it is defined as id

Both have the same function.

If I want to write code that is Runtime system aware. How do I create an object that is both and neither? I dream of that truly universal app.

if (catchOS10.5_or_iOS3.2) {
[MyStream setDelegate:myObj]
} else {
[MyStream setDelegate:myObjWithProtocol]
}

I have myHandlerClass which in the NEW os is
MyClass:NSObject

Thus my quandary.

Any suggestions?

-A

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

    Do you actually have trouble getting this to work on both versions? The two ideas are basically the same.

    You will definitely have to declare your delegate class as implementing the NSStreamDelegate protocol (which is a formal protocol, not an informal one, in the current SDK):

    @interface MyHandlerClass : NSObject <NSStreamDelegate> {
        // ...
    }
    -(void)stream:(NSStream*)theStream handleEvent:(NSStreamEvent)streamEvent;
    @end
    

    Since the “id” type is really just a typedef for a pointer to an Obj-C object, your pointer to your delegate class will both be an id as well as an NSObject:

    NSStream *myStream = [[NSStream alloc] init];
    MyHandlerClass *del = [[MyHandlerClass alloc] init];
    myStream.delegate = del;
    

    … should work on both SDKs. Or, if you’re creating your stream inside of your delegate class (a common idiom) you’d do:

    NSStream *myStream = [[NSStream alloc] init];
    myStream.delegate = self;
    

    to the same happy end.

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

Sidebar

Related Questions

I've followed the guide Setting Up Socket Streams and have effectively duplicated that code
In the iOS UIViewController code below, I connect to a server that uses a
I have implemented the NSStream delegate. I have implemented the same as Witap Application
I have a class which has it's delegate: @protocol SNIRCControllerDelegate - (void) serverTalked:(id)data; @end
Here is an example taken from Apple iPhone SDK project: @interface EADSessionController : NSObject
We're building an application for OS X, and we can't rely on our users
When I do Analyze to find out the potential memory leak, I get a
I am trying to download a file from an FTP server using an NSOperation.
I am downloading file with ftp protocol. Now, to check the ability of dealing
I am a newbie in Objective-C. I am trying to learn how to work

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.