views:

530

answers:

2

Extending the Utility Template

I'm working with the Xcode Utility template (Mainside/Flipside) and I need to add a new screen. I've added:

 docView.xib (copy of FlipsideView.xib)
 docView.m
 docView.h
 docViewController.m
 docViewController.h

In rootViewController.h I added:

 UINavigationBar *docNavigationBar;
 docViewController *docViewController;

 @property (nonatomic, retain) UINavigationBar *docNavigationBar;
 @property (nonatomic, retain) docViewController *docViewController;

In rootViewController.m, I synthesized the additions:

 @synthesize docNavigationBar;
 @synthesize docViewController;

I do import my .h into rootViewController.m:

   #import "docViewController.h"

When I try to compile I error out with:

RootViewController.m:22: error: syntax error before 'docViewController'

Warnings:

RootViewController.m:160: warning: property 'docViewController' requires method       '-docViewController' to be defined - use @synthesize, @dynamic or provide a method implementation

RootViewController.m:160: warning: property 'docViewController' requires the method 'setDocViewController:' to be defined - use @synthesize, @dynamic or provide a method implementation

What have I missed?

A: 

In rootViewController.h, looks like your declaration line:

docViewController *docViewController;

Should be:

FlipsideViewController *docViewController
Eric Petroelje
Sorry, FlipsideViewController *docViewController was a copy/paste error on my part. the line in my .h is: docViewController *docViewController
Alan
ahh, then the problem is as Jon describes below - your class and property names are the same, so the compiler can't figure out what you are talking about. Either rename the class, or rename the property/instance variable.
Eric Petroelje
Thanks!! All sorted out.
Alan
+1  A: 

Actually, I think he meant to have put docViewController (it's new view controller, right?). In any case, if this is what you meant, and not FlipsideViewController as Eric says, then your problem is that you named it the same as the property. Bad idea. Normal objective-C convention is to uppercase the first letter of your class names, then lowercase them when you use them as properties, etc.

docViewController *docViewController;

should be:

DocViewController *docViewController;

It will work a lot better that way :)

Jon Thomason
Thanks! Every day I learn a little more :)
Alan