Syntax Highlighting Objective-C in WordPress

I have added support for Objective-C to the Auto SyntaxHighlighter plugin for WordPress; it is in the official plugin as of version 2.3.3.

Here is some code for the sake of demonstration, based on content from Wikipedia’s article on Objective-C. Here is Person.h:

#import <Foundation/Foundation.h>

@interface Person : NSObject
{
    @private
        NSUInteger age;
}

@property(readwrite,copy,nonatomic) NSString *name;
@property(readonly,assign,nonatomic) NSUInteger age;

-(id)initWithAge:(int)age;
@end

And here is Person.m:

#import "Person.h"

@implementation Person
@synthesize name;
 
-(id)initWithAge:(NSUInteger)initAge
{
    self = [super init];
    if (self)
        age = initAge; // NOTE: direct instance variable assignment, not property setter
    return self;
}
 
-(NSUInteger)age
{
    return age;
}
@end

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

ipv6 ready