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

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:

iPhone Development Tips 2010-03-28 01:00:00 GMT
in cocoa
by Mark Damon Hughes

Objective-C is not the easiest language ever (all the expressive power of Smalltalk, all the syntax and memory complexity of C). Cocoa is a large and complex framework. The iPhone's UIKit is new and still quirky/buggy. Xcode is an… idiosyncratic… IDE. So this blog topic will collect some of my survival/sanity notes.


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