Re: Working with Notifications and NSFileHandle
Re: Working with Notifications and NSFileHandle
- Subject: Re: Working with Notifications and NSFileHandle
- From: Jason Coco <email@hidden>
- Date: Fri, 27 Jun 2008 20:32:09 -0400
On Jun 27, 2008, at 20:11 , Ken Thomases wrote:
On Jun 27, 2008, at 3:32 PM, Wan, Nathan (CIV) wrote:
I'm new to Objective-C and Cocoa and I am having trouble with the
notifications system. This I thought was just a small project to
write a native mac program to continuously read and write data from
a serial port to a file. It was suggested I use NSFileHandle to
maintain safe threads, as it can read the serial port
asynchronously; I had hoped this program would read the text file,
and as I changed it, there would be an output to the console.
Something simple to see the notification system in action:
//CODE
#import <Cocoa/Cocoa.h>
#import <Foundation/NSFileHandle.h>
#import <Foundation/NSString.h>
#import <Foundation/NSNotificationCenter.h>
Once you've imported Cocoa.h, I don't think you need to explicitly
import these Foundation headers.
You don't... if you're using AppKit, you should just include <Cocoa/
Cocoa.h>, if you're using Foundation,
you should just include <Foundation/Foundation.h>
#import <stdio.h>
If you were to use NSLog rather than printf, you wouldn't need this
either.
This is included for you when you include the main Cocoa or Foundation
header (actually, it's
included in CoreFoundation.h which gets included by Foundation.h which
gets included by
Cocoa.h.
Unless you define CF_EXCLUDE_CSTD_HEADERS, you get the following
headers every
time you use Cocoa, Foundation, or CoreFoundation:
<sys/types.h>
<stdarg.h>
<assert.h>
<ctype.h>
<errno.h>
<float.h>
<limits.h>
<locale.h>
<math.h>
<setjmp.h>
<signal.h>
<stddef.h>
<stdio.h>
<stdlib.h>
<string.h>
<time.h>
<inttypes.h>
<stdbool.h>
<stdint.h>
The Foundation/Foundation.h file includes all the Foundation headers
as well as CoreFoundation/CoreFoundation.h, the AvailabilityMacros.h
and the objc header files. So you never have to explicitly #include
these if you use any of the high-level frameworks.Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden