Tag: cocoa

NSXMLDocumentTidyHTML doesn't tidy some XHTML validation errors

I want to grab text from a list of web pages. I’ve done a bit of experimenting and found that the best way for my needs is via WebKit. Once the source of the page has been grabbed, I want to strip out all the HTML tags, by using the technique in this comment. Here’s […]

Getting the POSIX path of the Finder's front window

How can I get the POSIX path of the Finder window that is currently at the top of its window list? Preferably with some kind of Cocoa framework but I am open for anything. Background: I would need this because I want to make a selection of files matching a regex pattern, starting recursively from […]

Notification of autocorrect

Is there some notification that is posted or some other way to tell when in a NSTextView or any editable element that something has been autocorrected?

How Do you Drag-Move a Row in NSTableView?

If it were an iOS project, letting the user drag-move the selected row would be relatively easy. I think it’s something like – (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ return UITableViewCellEditingStyleNone; } – (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } – (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } – (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath […]

CGPathRef encoding

Is it possible to encode CGPathRef variables? I mean is there an encodeObject:forKey like method for CGPathRef variables?

Uncaught exception handler not called

I’m trying to catch exceptions on my Mac app so that I can log them in a custom log file. I’m implementing the exception handler like this: void uncaughtExceptionHandler(NSException *exception) { NSLog(@”It Works!”); } And I’m setting it in my -applicationDidFinishLaunching: method like this: NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); Then I cause an exception to test it like this: […]

There is really something like Objective C++?

I’m reading a post about iPhone programming and I’ve noticed that the talk about Objective C++, the code shown in the post looks mainly like Objective-C but there also are several snippets in C++. Is it really possible to program Cocoa from C++?

Compiling Objective-C app for Linux (API coverage)

I might be asking something strange here, but I’m unsure where to begin. The thing is that I am considering writing a command line tool on a Mac using Obj-C and the Foundation classes. But there is a very big risk that I would like to be able to compile it for different Linux distributions […]

String comparison for localization

What is the difference between NSString‘s localizedCaseInsensitiveCompare: and localizedStandardCompare: methods? I read the reference but did not get a proper idea of which one to use.

Implementing drag and drop in NSTableView

Can anyone help me to implement drag and drop in an NSTableView? I used this code below, but these methods are not getting called during execution. – (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard { // Copy the row numbers to the pasteboard. NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes]; [pboard declareTypes:[NSArray arrayWithObject:@”.gif”] owner:self]; [pboard setData:data forType:@”.gif”]; return YES; […]