Note that there are some explanatory texts on larger screens.

plurals
  1. POSet Delegate for Subview Controller
    text
    copied!<p>i'm sure there is a simple way to solve this problem, but I can't figure out.</p> <p>I got a TabBarViewController with several Views. In some of the Views i loaded Tableviews with XML based content.</p> <p>My XML Parser works fine, I tested it before in a separate Projectfile. The Problem is that my TableViewController, for which I created a XMLAppDelegate to manage the parsing of my xmlfiles, still sends the methods to the main delegation file of my Project.</p> <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainAppDelegate slices]: unrecognized selector sent to instance 0x6d1fd00' </code></pre> <p>Like the error message shows, he tries to send it to my MainAppDelegate, instead of the XMLAppDelegate.</p> <p>I implemented the XMLAppDelegate in my Controller Files and init the delegate this way:</p> <p>The .h File of my Controller</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @class XMLAppDelegate, NewsDetailViewController; @interface NewsViewController : UITableViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; { IBOutlet UITableView *newsTableView; XMLAppDelegate *appDelegate; NewsDetailViewController *ndvController; } @end </code></pre> <p>The .m File of my Controller</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // self.navigationItem.rightBarButtonItem = self.editButtonItem; appDelegate = (XMLAppDelegate *)[[UIApplication sharedApplication] delegate]; self.title = @"Slices"; </code></pre> <p>}</p> <p>The Controller is loading into the TabBarView as separate .xib file. In this nib file i connected the Delegate and Data Source to my XMLAppDelegate.</p> <p>I still get this Error in the Log and the Application crashes as I try to switch to the Tab wish the TableViewController in it.</p> <p>Hope you understand my problem. Maybe someone could tell me what I'm doing wrong here setting the Delegate to my XMLAppDelegate.</p> <p>EDIT:</p> <p>To explain what I want to do:</p> <p>I have a XMLParser class to parse the File, a Slice class to store the Elements and XMLAppDelegate. From this files i get my XML results stored in an Array with name "slices".</p> <p>To use the Elements of the Array, for showing it up as Table or textlabel, I connected the TableViewController to the XMLAppDelegate (which parses my XML Document using the XMLParser File and stores Data in the Array).</p> <p>The Items of this Array are previously declared in the Files as Strings like this</p> <pre><code>@property (nonatomic, readwrite) NSInteger sliceID; @property (nonatomic, retain) NSString *image; @property (nonatomic, retain) NSString *title; @property (nonatomic, retain) NSString *text; </code></pre> <p>But like i said, the parser works. I think my problem seems to be that I requested appDelegate.slices, but the selector is not my XMLAppDelgate. The Error says it uses the Main Delegate, which don't have any propertys of the xml Delegate file.</p> <p>The TabView loads the NewsViewController, which calls for the array in the XMLAppDelegate. I implemented the files, connected the Delegate to TableView as Data Source and Delegate, but still it seems to take the main delegate.</p> <p>That drives me crazy. The Project is a Company Profile for a great Wellness Motel. I get the Contents from the CMS as XML-Files and need to access them from XMLAppDelegate, that delivers the sites contents.</p> <p>Hope you understand my bad English. ;)</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