Kuba Suder's blog on Cocoa and web development

Testing Retina images on an older Mac

Categories: Cocoa, Mac 2 comments

If you build iOS apps, you’re used to providing all icons and other images in @1x and @2x versions for older and Retina screens respectively (or rather @2x and @3x now). And it’s pretty easy to test if all those versions work or not, by starting the right iOS simulator and looking at it scaled to 100%.

If you work on Mac apps, you should also include @2x images for Retina Macs now; but if you’re like me, you might have treated that so far as something not urgent that can be done later…

When you do get around to that, if you don’t have any Retina Mac yet, you’ll quickly notice a problem: how do you test your app on a Retina screen? There’s no OSX simulator in Xcode, after all.

Read more »

How to add icons to the menu bar on Yosemite

Categories: Cocoa, Mac 4 comments

Mac applications often add their icons to the notification area on the right side of the menu bar. That way they can show you some status changes by changing the icon image, and they can also save some space in your dock by removing the icon from there while still being easily accessible.

If you’re like me, you probably have quite a lot of those there:

The menu bar controls usually display their standard (preferably dark) icon on a standard background by default, and an inverted white icon on a blue background when clicked:

Read more »

A guide to NSButton styles

Categories: Cocoa, Mac 7 comments

I don’t know about you, but I never know which NSButton to pick from the Interface Builder library panel. When you start looking for a button there, this is what you see:

13 similar buttons in 3 rows

13 different buttons, all described with the same meaningless description:

The NSButton class is a subclass of NSControl that intercepts mouse-down events and sends an action message to a target object when it’s clicked or pressed.

Each of them looks slightly different, but which of these are you supposed to use in what context?

Read more »

How to fix NTFS support on OSX Lion

Categories: Mac 13 comments

After I upgraded my Mac to Lion this month, I’ve noticed that my NTFS drives stopped working. I’m using NTFS on my Windows XP partition and on a WD external drive. I’ve previously used MacFUSE and NTFS-3G, which is probably the most commonly used solution for people who want full NTFS access on OSX (as you probably know, by default OSX only provides read only support). However, that doesn’t work anymore on Lion. The problem is that MacFUSE is not maintained anymore and doesn’t work with a 64-bit kernel which is used by default in Lion.

First Google results usually point you to commercial solutions, but I’m not willing to pay for something as basic as filesystem support, which, frankly, Apple should have provided themselves long time ago. If you want to avoid paying, the right way is to replace latest stable MacFUSE with something that works on Lion.

Based on a few blog posts and comments I managed to find a way that worked for me, so I thought I’d put it all here in one place for others. The fastest way IMHO is to install packages from the command line, because – at least in case of NTFS-3G – it’s hard to tell from the website which version is the right one. I’m going to assume you haven’t lived under a rock for the last couple of years and you’re using Homebrew, not MacPorts. It’s not completely automatic – you’ll need to do a few things in the terminal, but it shouldn’t take more than a few minutes in total.

Read more »

Installing Sphinx on MacOSX from ports

Categories: Databases, Mac, Ruby/Rails 4 comments

A few days ago I spent a couple of hours trying to install the full text search engine Sphinx on my work computer in order to use it in my current project. I’m posting the details here, maybe this will save someone some time…

Firstly, if you’re like me and you look for some kind of binary package (like .dmg) first – sorry, there isn’t one. This leaves us two options: compiling Sphinx manually from the source, or using a package manager like MacPorts. I always avoid the first method if I have any other option, so I tried the ports.

Here’s the first problem: Sphinx requires MySQL, and while I have it on the disk of course, I’ve installed it from a dmg package, not from ports – which means it’s in a different path than ports expect and they have no idea where that is. I got scary errors like:

$ sudo port install sphinx
---> Building sphinx with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.​macports.​org_release_ports_textproc_sphinx/​work/​sphinx-0.9.7" && make all " returned error 2
Command output: sphinx.cpp: In member function 'virtual const char* CSphSource_MySQL::SqlError()':
sphinx.cpp:9397: error: 'm_tMysqlDriver' was not declared in this scope
sphinx.cpp:9397: error: 'mysql_error' was not declared in this scope
sphinx.cpp: In member function 'virtual bool CSphSource_MySQL::SqlConnect()':
...

Read more »

Interface Builder tips and tricks

Categories: Cocoa, Mac 1 comment

I read Apple’s tutorial about Interface Builder this week. Most parts of it told about rather basic things and were quite boring, but I’ve learned several useful tricks from it. IB, like most of Apple’s applications, has lots of hidden features which aren’t obvious at first, and can only be found by experimenting, by accident or by reading about them somewhere. Here’s a few things that I’ve learned from the tutorial – some of them are such hidden features, some are just things that weren’t mentioned in any source I’d read before.

Read more »

Generating scaffold interfaces in Cocoa

Categories: Cocoa, Mac 0 comments

I discovered an interesting feature in Interface Builder a few days ago. It seems that it can generate a scaffolding UI for you based on a CoreData model. It works like this: first you have to design a data model in XCode model editor (which you have to do anyway if you want to use Core Data; if you don’t, it won’t make sense to draw the model only to get the scaffold UI, it will be faster to make it yourself…). Let’s say you have a model like in this picture:

XCode data model editor

Read more »

Missing controls in IB 3.1

Categories: Cocoa, Mac 0 comments

I’ve upgraded XCode and Interface Builder to version 3.1 recently (the update doesn’t appear in the system update, you have to download it manually, and it’s deceitfully hidden – you have to register at Apple’s developer portal to get it…). Today I’ve noticed that after the update some advanced controls were missing in IB. I had a vague memory of having a lot of additional categories of controls below the standard ones (some image views and Quicktime controls, for example), and I couldn’t find them there. This screenshot confirmed that I wasn’t imagining it. Not that I need them right now, but I might need them one day…

I was able to figure this out after a bit of googling, so I’m posting a solution here so that maybe I’ll save someone a little time. The thing is, for some reason IB forgot about some of its plugins; I think it has something to do with the “known issues” entry here in the release notes. Plugin files are located inside system frameworks. Anyway, to get them back, you need to go to IB’s Preferences → Plugins, and using the plus below the list add several framework bundles from /System/Library/Frameworks. The list more or less matches the list from the release notes, but you’ll have to experiment a bit (e.g. ImageKit and Quicktime plugins were hidden inside Quartz, and DiscRecording inside DiscRecordingUI). And that’s it, all advanced controls are available again.