0

NSHost doesnot support to iphone... When I run this in simulator it works fine... But when I want to run in device means it gives an NSHost.h error....

I want to do this in device also. How could I fix this?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

1

NSHost is a private API on the iPhone and is thus not supported on the actual device.

drewh
  • 10,077
  • 7
  • 34
  • 43
1

Apple have published a technical note (QA1652) on "Using NSStreams For A TCP Connection Without NSHost."

There's a code sample on that page, but here's a summary:

You can do this by exploiting the toll-free bridge between NSStream and CFStream. Use CFStreamCreatePairWithSocketToHost to create CFStreams to the host, and then cast the resulting CFStreams to NSStreams.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152