skip main content

Posts Tagged ‘OSX’

Logging/Debug setup in Xcode 4

posted by Duncan at 9:10 am on May 31st, 2011

Here’s a little snippet of how I manage logging in my applications with Xcode 4. I’m sure it works just fine in 3 too, but this is more of a reminder for me as it’s something I always forget how to do when starting a new project.

Firstly I update the *_Prefix.pch file that lives in the Other Resources directory so it also contains the snippet below. I use the Prefix code posted by Marcus Zarra which seems to work just fine for me:

#ifdef DEBUG
  #define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
  #define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
  #define DLog(...) do { } while (0)
  #ifndef NS_BLOCK_ASSERTIONS
    #define NS_BLOCK_ASSERTIONS
  #endif
  #define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#endif
 
#define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)

Next I update my project by adding the DEBUG=1 flag to the preprocessor settings. Click on your application target, and select the Build Settings tab is selected along with All and Combined. I then do a search for ”- preprocessing” which should leave you with the Preprocessor Macros remaining. Now just DEBUG-1 to the correct one, as the photo below shows.

DEBUG flag

Hope that saves someone some time. Oh, and if anyone has any improvements I can make to this, I’d love to here them.

Introducing TrainMode 1.0, now in the Mac App Store

posted by Duncan at 8:47 am on March 31st, 2011

After the relative success in the iPhone App Store of Hydrate and Keycell, I fancied getting something into the Mac App Store too. I had tried to submit RadioAunty, but had it rejected because it contained Flash! (yeah thanks). I needed other ideas.

Whist getting onto the train to work one morning, getting out my MacBook, and going through the same procedure of, turning off the Wifi, muting the volume, and turning down the screen brightness, it occurred to me that I could streamline this into a simple application that lives in your status bar. One click to turn everything off, one click to turn it back on again. TrainMode was born.

TrainMode #2

The application actually allows you to adjust a few things. Like which things you would like switched off, and how quiet you want the volume muted or how dim you want the screen to go. You can even set it to automatically de-activate after a period of time.

I have been using it every day for about a month now, and whilst it’s hardly life changing, it is proving convenient. I’d love to hear what you think? Get it from the App Store using the link below. I have also provided a few promo codes below. First come first serve.

Download TrainMode from the App Store

# TrainMode promo codes
T7XXEW4A3JPL
HPAHFM9XH9MA
3N6XP9J9FM37
EM4PRKAFR64L
3LKYM3NH6HF9
AMLLARNMY94N
4J4P3HA39XJ7
EHTK36FFN3FH
7AP3RXETWLWA
4NPEPHLYN4NK
4T3LF9R9AT3X
KE9PN7HMK6N4
AXX49PMYP3KX
L6XPLN3HY47L
P7PXAKXTRLAY
3M6EWTAXFAJ7
W3LH66P33J9N
HA37PW9L3WYP
74NJK69XYNTM
HEAJR6TNL99L
7X93HRF9LFYJ
WRPTNMF7MYP4
FJ3HH4K9E7LJ

If you could let me know in the comments if you used one, so I can strike it out.

RadioAunty 2.1 gets 7 day catchup and BBC local radio support

posted by Duncan at 11:48 am on October 20th, 2010

After the excitement of getting liveText into RadioAunty, I thought I’d get my head down and implement the two biggest features I get asked for. These being:

  • Choose from any of the 66 online BBC Radio stations
  • Navigate through the past 7 days ondemand listening

local BBC radioSee more RadioAunty photos

So, this update has taken quite a few train journeys, but I hope you’ll agree with me in thinking the hard work has paid off. I’m really quite pleased with the results. The application now packs quite a punch feature wise, but still fulfils its primary remit of being really simple to operate, hiding any extra functionality from those that just want to listen to the Radio.

As always, if you’re not interested in reading this stuff, your current version will autoupdate, or just head off to http://whomwah.github.com/radioaunty and download it.

Local Radio Support. Currently in RadioAunty, you can only listen to the national stations. There are many more BBC stations available, specifically local ones. You can now go into the preferences, and choose from all the BBC stations, selecting which ones appear in the Listen menu.

local radioSee more RadioAunty photos

The ability to now opt-in to these extra stations is a design choice. The most important thing for me, is that RadioAunty is just a simple radio (the same goes for TellyBox as a television). All these updates I build bring great extra functionality, but my first assumption is that people couldn’t care less, and just want to listen to the radio. Anything I do to make this more complex, just means they won’t use it.

So, now, not only do you have the opportunity to listen to these other stations easily, you also get the current schedule and the ability to play catchup shows too, all within a very simple interface.

7 day catchupSee more RadioAunty photos

7 Day Catchup. Talking of catchup, this brings me on to the other big feature I have added. I really think this one takes RadioAunty to a new level, and why I still believe native radio listening applications, with their ability to spread the UI around desktop, will always be far superior to anything you could do on a website. The ability to simply see all of the available catchup programs for the last 7 days in simple menus. If you can click them, you can play them. So if you’re listening to Radio 1 on Monday and would like to listen to the Essential Mix you missed because you were in bed, you can now simply navigate to the previous Friday, and see the essential mix in the drop down menu.

catchupSee more RadioAunty photos

Also, as you can see above, when you hover on any of these menu items, you also get a brief synopsis and how long there is left to listen.

So, if you like this application and it’s features, please spread the word. I really believe this is a great way to listen or catch up on BBC Radio.

RadioAunty 2.0 released, BBC LiveText and LastFM scrobbling added

posted by Duncan at 10:12 pm on September 23rd, 2010

After talking about XMPP and pubsub in my last post, the I have just pushed said version 2.0 release of RadioAunty. It took a bit longer than I expected, mostly due to me adding the LastFM scrobbling support I alluded to.

lastfm

A few things I should mention about these new features. RadioAunty is written by me, to try interesting things with the BBC’s radio player, that the BBC chooses not to do themselves. This means features may come and go. So the Twitter support is now gone. Due in part to the fact I stopped using the service day-to-day a while back, and didn’t want to re-implement the OAuth stuff.

The new BBC Livetext support is a little bit experimental. Whilst the service is stable, I can’t guarantee it will be available all the time, although I’ve seen no problems to date. This and the fact that it currently will not work if you don’t have direct access to the internet, for example if you are behind a firewall and go through a proxy. If someone fancies adding SOCKS support, that would be wonderful.

The LastFM scrobbling support is also a bit experimental. It’s using the API 2.0 Beta which is still actively being worked on. I created a little Scrobble class to do the work. Do note though, that the app will only scrobble based on the now playing information provided by the liveText service. Every tracked played is not always sent via liveText, so you may well see some tracks not showing up in your Recently Listened Tracks.

Enjoy.

My Garmin eTrex Vista HCx and OSX

posted by Duncan at 9:05 pm on June 10th, 2010

A quick post of my learnings when researching the best setup for my Garmin eTrex Vista HCx as most of what I initially found was old, PC only, or just plain wrong.

Garmin eTrex Vista HCx

I chose this GPS device because it was reasonably cheap, expandable, and allowed me to upload maps to the device, and visa-versa. I also wanted to use the power of OpenStreetMap, rather than pay Garmin lots of money, and my research showed me this was possible.

So, rather than talk about all the things that I couldn’t find or do, I’ll just run through the good stuff. Here’s a run down of all the useful software I found.

  • OSM/Computerteddy Garmin IMG tile calculator

    Create a bounding box on a map of the world, and it will return an OSM IMG to use on your device. There’s even a great bookmarklet to use on the OpenStreetMap site. This is an awesome site.

  • geofabrik.de

    A great resource of maps of the world. I don’t speak German, but you can get the idea of what you’re able to download.

  • http://fredericbonifas.free.fr/

    Detailed map of France. I used this on a recent cycle tour, and it was invaluable.

  • TrailRunner

    TrailRunner is a route planning Mac software for all kinds of long distance sports like running, biking, hiking, inline-skating, skiing and more. It’s free, but a donation of 25 Euros will stop prompts. It’s a fantastic bit of software.

  • LoadMyTracks

    This free utility works hand-in-hand with TrailRunner. It will send and receive data to and from the eTrex. It can also be used to translate data between the popular GPX and KML (Google Earth) formats.

Finally there is the OpenStreetMap Garmin page which has the useful information about getting all this data onto the device, and much more.

nextKeyView and moving between NSTextfield and NSButton

posted by Duncan at 3:57 pm on May 26th, 2010

This caught me out today, so I thought I’d share to save someone else scratching their head. The problem I was having was thus. In interface builder I had a window with an NSTextField and an NSButton. I want to be able to tab between them. I did what I thought was correct:

  1. Set the intialFirstResponser for the NSWindow to be my NSTextField
  2. Set the NSTextField nextKeyView to be the NSButton
  3. Set the NSButton nextKeyView to be my NSTextField

But this was not working in the app! It Turns out that in the Apple > System Preferences > Keyboard there is a setting that allows you to press Tab to move keyboard focus between:

  • Text boxes and lists only
  • All controls

I think the top one is set by default. Once changed to All controls everything worked as expected.

Fun with Quartz Composer in Snow Leopard and the BBC Radio Schedule

posted by Duncan at 12:34 pm on October 7th, 2009

I’ve just posted on the BBC Radio Labs blog about some tinkering with Quartz Composer I’ve done. Please read the full article there, but in short, I’ve created a Quartz Composition that you can install as a Screen Saver, that reads in the BBC National Radio Schedule and rolls through each station showing who’s on and displays a pretty picture. Oh, and I think it all looks very pretty.

BBC Radio Screen Saver

Head on over to the Radio Labs site to download and install on your machine. Please note though, it’s for OSX 10.6 Snow Leopard only.

Another iPhone Code Sign Error Fix solution

posted by Duncan at 3:10 pm on May 10th, 2009

Dam, this took far to long to suss out !!! I even left the London Open Hack 2009 early because I was unable to install development apps I was working on onto my iPhone, and it was proving so frustrating I decided to go home to try and fix it there … Dam!!!

So the error I was getting was:

Code Sign error: The identity 'iPhone Developer' doesn't match any valid 
certificate/private key pair in the default keychain

I won’t bore you with all the variations, forums, websites read and ways I tried to solve this, and will leave you with the solution in this case. The problem was that the KeyChain App had changed it’s default keychain over to ‘system‘ and it should have been ‘login‘ as this is where all my keys and certificates are installed. Also, the default keychain is where Xcode looks. The default keyChain in the one in the keychains list that is bold. To make one the default, you right click on it and select the ‘make default’ item from the list.

Yep, That’s It!! and to be honest the error message make a little more sense now I’ve fixed it … Dam!

Using Cocoa to keep an app window always on top

posted by Duncan at 4:39 pm on April 11th, 2009

Sometimes you want your application to keep one of it’s windows always-on-top. A chat application like Adium for example, allows you to keep your conversation window always-on-top so you can follow the conversation whilst still using other applications. In the TellyBox application I wrote, this functionality is also very useful, as you can watch tv whilst still working in other applications.

So the basic implementation was fairly simple. You just use the windowDidResignMain notification, and then re-set the window level a more fitting one. Below I have also wrapped around a preference setting:

- (void)windowDidResignMain:(NSNotification *)notification
{
  // It's always nicer if the user has a choice
  if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAlwaysOnTop"] == YES) {
    [[self window] setLevel:NSFloatingWindowLevel];
  } else {
    [[self window] setLevel:NSNormalWindowLevel];
  }
}

My TellyBox application allows you to go fullscreen via the existing Flash application embedded in a webkit view. Using just the basic implementation meant that when going into fullscreen mode the frame of the original window remained in view. To fix this I added this extra bit of code, which gets used via the firing of another useful notification windowDidBecomeMain :

- (void)windowDidBecomeMain:(NSNotification *)notification
{
  [[self window] setLevel:NSNormalWindowLevel];
}

which sets the window level back to it’s default value of 0 when it becomes the main window i.e when you select it.

I hope this little snippet helps people trying to achieve the same effect in their apps.

Lookup – A simple Mac utility that wraps ldapsearch

posted by Duncan at 11:53 am on April 7th, 2009

I work on a Mac at work, and it has always been a bit slow searching for other staff members in our global address book. Like other big organisations we have some directory services which we can use LDAP to interrogate. The seemingly standard way for apps to poll these services is asynchronously every second or so, so that you’re getting results back quickly in the background. In reality this can be clunky if your network is slow, or the directory is very big.

I wanted something simpler, and a gui that gave me was suited to my work requirements. Lookup displays glance-able contact details straight away, letting you copy, paste and drag this data around. It also has simple shortcuts like double clicking the contact to start a new email to that person.

Lookup does not poll asynchronously, it does one request per search and just looks through some key attributes. It seems to work very well, and has been customised for my workplace, but is generic enough for someone to tweak it to suit their companies needs.

Lookup

It wraps ldapsearch, which is a command line app that comes free on your mac. When I say wraps, it’s not a complete wrapper, but wraps enough to create an app of this kind. Ldapsearch app did everything I wanted in search terms, and gave me a chance to use NSTask and NSPipe which I know will be useful in the future.

You can get the source over at Github. Why not try and tweak it to work for your company. You never know, just compiling it and updating the settings in the preferences menu may be enough.

Just to be clear, this app does NOT give you access to the BBC address book, just incase you thought I’d gone mad.


back to the top