ABOUT
[Mark]

Hi, Mark Damon Hughes here.

I write neat little strategy and role-playing games for the iPhone.

I also help other people write their apps for the iPhone; if you need a contractor, I can solve any problem for you.

You can reach me by email at
mark@markdamonhughes.com

Visit my software gallery at
http://markdamonhughes.com/

ARCHIVE
By Category:
By Author:
By Date:

Mark Damon Hughes

MDH's Software Blog

Site Restored 2010-12-18 00:07:00 GMT
in blog
by Mark Damon Hughes

Okay, site is restored. Comedy of errors problems resolved, shoemaker's children are now shod.

Scripting in Xcode 4 2010-07-23 20:24:00 GMT
in cocoa
by Mark Damon Hughes

The new Xcode 4 beta is up at ADC, and I'm learning its quirks and changed keyboard keys, and just as quickly remapping them back to my keys.

But one thing is missing: Scripts, in particular my accessors.py script isn't available.

There's a way to work around that, though: Services. If you open Automator, it'll prompt you to create a project. Pick Service, give it some recognizable name. Now choose Run Shell Script, click "Replaces selected text", type the path of your script (using $HOME for home, not ~), and save… And it's magically ready in the Services menu.

To give it a key binding, you'll need to use System Preferences, Keyboard, Services. I'm not sure how (or if) you can change the category from Text to Development, but at least you can extend Xcode with scripts now.

My Cocoa dev scripts

UIWebView Background 2010-03-28 01:08:00 GMT
in cocoa
by Mark Damon Hughes
Problem

UIWebView leaves an ugly gray background when dragged up or down. You would like to have it show the view behind it instead (for performance and readability, please use a solid color or VERY simple pattern).

Solution

First, give the UIWebView clear background and non-opaque, either in IB or code:

Then make the page displayed have a clear background:

UIView Frames in GDB 2010-03-28 01:07:00 GMT
in cocoa
by Mark Damon Hughes
Problem

When debugging display code, you want to see the frame of a component.

Solution

You can't directly display a CGRect in gdb, but you can use the NSStringFromCGRect() function:

See also the UIKit Function Reference for many more useful functions.

Properties and Accessors 2010-03-28 01:06:00 GMT
in cocoa
by Mark Damon Hughes
Problem

Creating a property takes up to 4 lines of repetitive code in Cocoa: The ivar declaration and @property in foo.h, @synthesize and dealloc in foo.m.

Solution

You can use the commercial product Accessorizer, which is very powerful, but too big and full of clicky buttons and switches for my needs. I just wanted a tool to do minimal analysis of ivars and give me the text, which I can copy into place.

Download accessors.py and follow the instructions in the comments.

iPhone Provisioning Profiles 2010-03-28 01:05:00 GMT
in cocoa
by Mark Damon Hughes
Problem

You install new certificates or mobileprovision profiles, but Xcode isn't picking them up.

Solution

Restart Xcode. It only correctly acquires new profiles at startup.

Cocoa Macros 2010-03-28 01:04:00 GMT
in cocoa
by Mark Damon Hughes
Problem

Some Cocoa methods and functions are just too verbose for normal use.

Solution

Add these to your Foo_Prefix.pch header (or to your own header which you import regularly):

I'm "cheating" here, using NS prefixes for functions I created, not Apple. But using my own prefix would be very confusing for many of these.

New Project Checklist 2010-03-28 01:03:00 GMT
in cocoa
by Mark Damon Hughes
Problem

Setting up a new Xcode project requires a few steps:

Solution
  • File|New Project, pick template, choose dir (~/Code/CodeTouch or ~/Code/CodeMac), enter name.
  • Project|Edit Project Settings:
    • Build tab
    • Configuration: All Configurations
    • Treat Warnings as Errors: YES
    • Configuration: Debug
    • Preprocessor Macros: double-click, +, DEBUG=1
Code Snippet Organization 2010-03-28 01:02:00 GMT
in cocoa
by Mark Damon Hughes
Problem

You have common code used in many projects, usually just bits and pieces. Storing it in text files or even Yojimbo or TextExpander is too much trouble and the code can get stale and no longer compile.

Solution

Create an Xcode project named "Clipboard". For every snippet, create a source file with just one method. Every time you add a snippet, Build|Clean and Build|Build.

Xcode Preferences 2010-03-28 01:01:00 GMT
in cocoa
by Mark Damon Hughes
Problem

The default layout and key bindings in Xcode are dysfunctional.

Solution

In Preferences|General (with NO project open): Layout: All-in-One. You can still double-click a file to open in a new window, but this default keeps you focused on ONE task at a time.

In Preferences|Building: Build Results Open: Always. I set the filter dropdown to "Issues Only", but YMMV.

In Preferences|Debugging: Debug on Start: Open Console. Seeing NSLog output is essential.

In Preferences|Key Bindings, I set these:


Pages: 0 1 2
METADATA
Copyright © 2008 by Mark Damon Hughes | Email Feedback | [RSS 2.0]