SubEthaEdit and Objective-C

Posted by dom Mon, 20 Mar 2006 09:30:00 GMT

Obviously when coding, we prefer SubEthaEdit over the Xcode internal editor. There is collaboration, of course, you don't get that in Xcode. But there is more. For example, take these two examples of Syntax Highlighting:

Xcode:

#import "NSNetServiceTCMAdditions.h"
#import "NSStringTCMAdditions.h"

@implementation NSNetService (NSNetServiceTCMAdditions)
- (NSArray *)TXTRecordArray {
    if ([self respondsToSelector:@selector(TXTRecordData)]) {
        NSMutableArray *result   =[NSMutableArray array];
        NSData         *TXTRecord=[self TXTRecordData];
        DEBUGLOG(@"RendezvousLogDomain", AllLogLevel,@"%@ - Data: %@",
                 [[[NSString alloc] 
                    initWithData:TXTRecord 
                    encoding:NSMacOSRomanStringEncoding] autorelease],
                 TXTRecord);
                 
        unsigned char *bytes=(unsigned char *)[TXTRecord bytes];
        unsigned char *bytesEnd=bytes + [TXTRecord length];
        while (bytes<bytesEnd) {
            unsigned char length=*bytes++;
            if (bytes+length > bytesEnd) {
                length = bytesEnd-bytes;
            }
            if (length>0) {
                NSString *string=[[NSString alloc] 
                                    initWithBytes:bytes 
                                           length:(unsigned int)length 
                                         encoding:NSUTF8StringEncoding];
                if (string) {
                    [result addObject:string];
                    [string release];
                }
            }
            bytes+=length;
        }
        DEBUGLOG(@"RendezvousLogDomain", AllLogLevel,@"Array: %@",result);
        return result;
    } else {
        return [[self protocolSpecificInformation] 
                   componentsSeparatedByString:@"\001"];
    }
}
@end

SubEthaEdit:

#import "NSStringTCMAdditions.h"

@implementation NSNetService (NSNetServiceTCMAdditions)
- (NSArray *)TXTRecordArray {
    if ([self respondsToSelector:@selector(TXTRecordData)]) {
        NSMutableArray *result   =[NSMutableArray array];
        NSData         *TXTRecord=[self TXTRecordData];
        DEBUGLOG(@"RendezvousLogDomain", AllLogLevel,@"%@ - Data: %@",
                 [[[NSString alloc] 
                    initWithData:TXTRecord 
                    encoding:NSMacOSRomanStringEncoding] autorelease],
                 TXTRecord);
                 
        unsigned char *bytes=(unsigned char *)[TXTRecord bytes];
        unsigned char *bytesEnd=bytes + [TXTRecord length];
        while (bytes<bytesEnd) {
            unsigned char length=*bytes++;
            if (bytes+length > bytesEnd) {
                length = bytesEnd-bytes;
            }
            if (length>0) {
                NSString *string=[[NSString alloc] 
                                    initWithBytes:bytes 
                                           length:(unsigned int)length 
                                         encoding:NSUTF8StringEncoding];
                if (string) {
                    [result addObject:string];
                    [string release];
                }
            }
            bytes+=length;
        }
        DEBUGLOG(@"RendezvousLogDomain", AllLogLevel,@"Array: %@",result);
        return result;
    } else {
        return [[self protocolSpecificInformation] 
                   componentsSeparatedByString:@"\001"];
    }
}
@end

So what are the differences and why do we like SubEthaEdit better?

  • Cococa Class and Constant recognition
    NSString instead of NSString
    NSUTF8StringEncoding instead of NSUTF8StringEncoding
    This way you get instant validation if the things you wrote exist, or you put in a typo.
  • Selector highlighting
    NSString *string=[[NSString alloc] 
                        initWithBytes:bytes 
                               length:(unsigned int)length 
                             encoding:NSUTF8StringEncoding];
    
    instead of
    NSString *string=[[NSString alloc] 
                        initWithBytes:bytes 
                               length:(unsigned int)length 
                             encoding:NSUTF8StringEncoding];
    
    We can't live without that.
  • Memory Management
    All the retain count affecting methods (new, alloc, allocWithZone, copy, copyWithZone, mutableCopy, mutableCopyWithZone, retain, release, autorelease) are colored in a bold dark red so you can see instantly if a pair is missing. We are glad to be leak free in SubEthaEdit and this is one of the reasons. Memory management in Cocoa isn't hard, but you have to be thorough - and this helps a lot.
These three things really make all the difference in the world to us. What do you think?

Posted in  | Tags , ,  | 6 comments

Comments

  1. Colin Barrett said about 8 hours later:
    It'd be interesting to try and hack Xcode (perhaps through injecting and poseAsClass:ing NSView) and put the SEE view directly in there instead of using the solution described in the article after this. But seriously, SEE has some pretty awesome hilighting. I also like how you can do import and export. It's very useful for sharing between people.
  2. alexs said 3 days later:
    Looks like the Objective-C syntax highlighting in SubEthaEdit is pretty mature, which isn't suprising considering that you guys are full time Cocoa developers. If I had known how weak the syntax highlighting and symbol recognition in SubEthaEdit was for Java I never would have purchased it (only demo'd it on a C++ project). =( (And yes, I bugged it: SEE-966, never got a response).
  3. map said 3 days later:
    Your bug is currently scheduled for 2.4. You should be able to see that however when you log in in the bug tracker. If you have problems with your account, please contact me via email.
  4. dom said 3 days later:
    @alexs: Thanks for your bug report on this. As we don't code much java ourselves we need this information. Rest assured that it isn't ignored, but we only contact bug reporters when we need more information, have a temporary workaround or ship the version in which we fixed the issue, so that it can be verified.
  5. art supplies said over 4 years later:

    Like the coding and my application is working properly.Thanks for the coding.

  6. Wedding program samples said over 4 years later:

    Really nice post here. I must say that Brilliant work. Thanks buddy. Hope all get pleasure so much like me.

(leave url/email »)

   Comment Markup Help Preview comment