Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>To declare <code>delegate</code>, in the table view controller header file, I include <code>@class MainAppDelegate;</code> and in the <code>@interface</code> I declare a[n instance variable] <code>MainAppDelegate *delegate;</code>. In the table view controller's <code>@implementation</code> I do <code>@synthesize delegate;</code>.</p> </blockquote> <p>So you have forward-declared the class name <code>MainAppDelegate</code> and used it to declare an instance variable. Since you are @synthesizing a property, I assume you declared one of those, too.</p> <blockquote> <p>I currently use it to fill a Table View (a SubView) like this:</p> <pre><code>cell.textLabel.text = [[[delegate contentArray] objectAtIndex:indexPath.row] name]; </code></pre> <p>This works, but I get a warning:</p> <blockquote> <pre><code>warning: no '-contentArray' method found </code></pre> </blockquote> <p>It won't compile as:</p> <pre><code>cell.textLabel.text = [[delegate.contentArray objectAtIndex:indexPath.row] name]; </code></pre> <p>I get this in that case:</p> <blockquote> <pre><code>error: request for member 'contentArray' in something not a structure or union </code></pre> </blockquote> </blockquote> <p>That's because the compiler doesn't know what methods or properties <code>delegate</code> has. You've declared the name of its class, but the compiler doesn't know anything else about it, because you haven't provided an <code>@interface</code> for that class.</p> <p>The solution is to <code>#import</code> the header file for the delegate class into the table view controller class's implementation file, probably immediately after <code>#import</code>ing the table view controller class's own header.</p> <p>Also, I suspect that the array more properly belongs to the table view controller than to the app delegate, but I don't know enough about Cocoa Touch to say for sure.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload