Posted by dom
Mon, 20 Mar 2006 10:00:00 GMT
Having talked about how we prefer using SubEthaEdit over the internal editor of Xcode let's talk about how you enable SubEthaEdit as external editor in Xcode. To do this go in Xcode's Preferences to the File Types Pane. Minimally you need to open the text type and change the sourcecode subtype by using the dropdown.
If you want to use SubEthaEdit for all plain text files like I do, I recommend also changing text.xml, text.html, text.plist and text.script. The final window with these setting applied looks like this:
So what do you get by this change? Files double clicked in an Xcode project now are openend in SubEthaEdit and of double clicks on error jump to the error line in SubEthaEdit. Moreover if you press compile and there are changed files in SubEthaEdit you are asked if you want to save them first. All things expected.
Sadly, Xcode hasn't (yet) an api for setting breakpoints, that means if you want to set or remove breakpoints you still have to use the Xcode internal editor. We just switched to open all our text files in SubEthaEdit - so double clicking won't do. Thankfully there is an easy way: right- or ctrl-click on the file you want to open in the project view and choose Open As… → Source Code File.
Posted in SubEthaEdit | Tags subethaedit, xcode | 8 comments
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 SubEthaEdit | Tags objective-c, subethaedit, xcode | 5 comments