#import "MyController.h"
@implementation MyController
#pragma mark -
#pragma mark Startup and Shutdown
- (id) init
{
if (self = [super init])
{
_mailboxes = [[NSMutableArray alloc] init];
}
return self;
}
- (void) dealloc
{
[_mailboxes release];
[super dealloc];
}
#pragma mark -
#pragma mark Simple Accessors
- (NSMutableArray *) mailboxes
{
return _mailboxes;
}
- (void) setMailboxes: (NSArray *)newMailboxes
{
if (_mailboxes != newMailboxes)
{
[_mailboxes autorelease];
_mailboxes = [[NSMutableArray alloc] initWithArray: newMailboxes];
}
}
@end
------------------------------------------------------------------------------------------
As the above sample code shown, what do the #pragma sentences mean?
I have read the Programming in Objective-C, but it doesn't make me understood yet. Could someone explain more clearly? Thank you!
Paragraph in Programming in Objective-C:
The #pragma Directive
General Format:
#pragma text
This causes the preprocessor to perform some implementation-defined action. For example, under the pragma
#pragma loop_opt(on)
causes special loop optimization to be performed on a particular compiler. If this pragma is encountered by a compiler that doesn't recognize the loop_opt pragma, it is ignored.
The special keyword STDC is used after the #pragma for special meaning. Current supported switches that can follow a #pragma STDC are FP_CONTRACT, FENV_ACCESS, and CX_LIMITED_RANGE.
@implementation MyController
#pragma mark -
#pragma mark Startup and Shutdown
- (id) init
{
if (self = [super init])
{
_mailboxes = [[NSMutableArray alloc] init];
}
return self;
}
- (void) dealloc
{
[_mailboxes release];
[super dealloc];
}
#pragma mark -
#pragma mark Simple Accessors
- (NSMutableArray *) mailboxes
{
return _mailboxes;
}
- (void) setMailboxes: (NSArray *)newMailboxes
{
if (_mailboxes != newMailboxes)
{
[_mailboxes autorelease];
_mailboxes = [[NSMutableArray alloc] initWithArray: newMailboxes];
}
}
@end
------------------------------------------------------------------------------------------
As the above sample code shown, what do the #pragma sentences mean?
I have read the Programming in Objective-C, but it doesn't make me understood yet. Could someone explain more clearly? Thank you!
Paragraph in Programming in Objective-C:
The #pragma Directive
General Format:
#pragma text
This causes the preprocessor to perform some implementation-defined action. For example, under the pragma
#pragma loop_opt(on)
causes special loop optimization to be performed on a particular compiler. If this pragma is encountered by a compiler that doesn't recognize the loop_opt pragma, it is ignored.
The special keyword STDC is used after the #pragma for special meaning. Current supported switches that can follow a #pragma STDC are FP_CONTRACT, FENV_ACCESS, and CX_LIMITED_RANGE.