thomasguenzel.com

Apps/Programming

Tag: mac

Automatically Update the Title of a View-Controller Based NSTabViewItem

Currently I’m working on yet another Mac app, where I have a NSTabView with multiple tabs that each represent a view controller.
I noticed that when I set my view controller’s title with

self.title = @"some other title"

nothing changes. So I wrote a small NSTabViewItem subclass that updates the title automatically by observing the title key of the view controller.

The code is on github and you can find the important part below.

@implementation GNTabViewItem

-(void)dealloc {
	[self.viewController removeObserver:self forKeyPath:@"title"];
}

-(void)setViewController:(NSViewController *)viewController {
	[self.viewController removeObserver:self forKeyPath:@"title"];
	[super setViewController:viewController];
	[self.viewController addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:nil];
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
	if([keyPath isEqualToString:@"title"] && object == self.viewController) {
		self.label = self.viewController.title;
		return;
	}
	[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}

@end

Search and Replace on the Mac App Store

Just a few minutes ago my newest app, Search and Replace, went online! It’s a helpful tool if you need to perform search and replace operations on multiple files. You can also use regular expressions for complex operations.

Take a look at it here.

Setting up a File Type for your Mac App

As I often have problems setting up a custom filetype for my Document-Based Applications I decided to write a short tutorial on how to do it (actually just one image). You just need to enter most of the information twice, once for the Document Type and once for the Exported UTI.
Look at those two lists for what types you have to choose:
List of Uniform Type Identifiers
Wikipedia Article about MIME (including common types)

filetypetut

SpaceDebris online

My newest game, SpaceDebris, is now online in the App Store and Mac App Store. Check it out!

© 2017 thomasguenzel.com

Theme by Anders NorenUp ↑