Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, you're storing your newly-allocated <code>MainSubView</code> in a <code>UAModalPanel</code> pointer although the properties you need to access are part of your <code>MainSubView</code> subclass.  Try changing the <code>MainSubView</code> initialization to:</p> <pre><code> MainSubView *mainSubModalPanel = [[[MainSubView alloc] initWithFrame:self.view.bounds] autorelease]; </code></pre> <p>Now you should be able to set <code>dishName</code> and <code>mainTitle</code>'s <a href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UILabel_Class/Reference/UILabel.html#//apple_ref/occ/instp/UILabel/text" rel="nofollow" title="UILabel class reference - text property"><code>text</code></a>:</p> <pre><code> mainSubModalPanel.dishName = @"Pizza!"; mainSubModalPanel.mainTitle.text = @"Moar Pizza!"; </code></pre> <p>And then add it as a subview and whatever else as you have above <em>(I like to set up an object completely before passing ownership since it tends to lead to fewer glitches)</em>.</p> <hr> <p><strong>Minor Notes:</strong></p> <p>Your <code>NSString *dishName</code> property would probably be better to have the <code>copy</code> modifier rather than <code>retain</code>.  Foundation types that have mutable subtypes <em>(i.e. NSString has a NSMutableString subclass)</em> are subject to being passed a mutable subclass that can be changed from the outside.  Generally, this isn't what you want and leads to bugs <em>(unless of course you've asked for an NSMutableString explicitly)</em>, and using <code>copy</code> makes sure that whatever you're passed stays that way:</p> <pre><code>@property (nonatomic, copy) NSString *dishName; </code></pre> <p>Also, if you're planning on having MainSubView's <code>mainTitle.text</code> match <code>dishName</code>, you may want to consider specifying a custom setter method for <code>dishName</code> that sets the <code>mainTitle.text</code> automatically like this:</p> <pre><code>- (void)setDishName:(NSString *)newDishName { BOOL notTheSameStringInstance = (newDishName != dishName); BOOL notIdenticalStringContents = ![newDishName isEqualToString:dishName]; if (notTheSameStringInstance &amp;&amp; notIdenticalStringContents) { [dishName release]; dishName = [newDishName copy]; mainTitle.text = dishName; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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