I’m sending data back and forth through the Bonjour protocol. All the packets are sent as NSData and usually converted to strings; but what if I need to receive an image? This is the process that will be going on.
- Client requests the
NSImage - Server sends the requested
NSImageas aNSDatapacket - Client receives
NSData - Client checks if the data is an image
- ????
- PROFIT?
Could I attempt to convert the data into an image and catch the error (which would mean it’s not an image)?
Use:
If
datais not valid image data, thenimagewill benil.