i’m sure there is a simple way to solve this problem, but I can’t figure out.
I got a TabBarViewController with several Views. In some of the Views i loaded Tableviews with XML based content.
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.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainAppDelegate slices]: unrecognized selector sent to instance 0x6d1fd00'
Like the error message shows, he tries to send it to my MainAppDelegate, instead of the XMLAppDelegate.
I implemented the XMLAppDelegate in my Controller Files and init the delegate this way:
The .h File of my Controller
#import <UIKit/UIKit.h>
@class XMLAppDelegate, NewsDetailViewController;
@interface NewsViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *newsTableView;
XMLAppDelegate *appDelegate;
NewsDetailViewController *ndvController;
}
@end
The .m File of my Controller
- (void)viewDidLoad {
[super viewDidLoad];
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
appDelegate = (XMLAppDelegate *)[[UIApplication sharedApplication] delegate];
self.title = @"Slices";
}
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.
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.
Hope you understand my problem. Maybe someone could tell me what I’m doing wrong here setting the Delegate to my XMLAppDelegate.
EDIT:
To explain what I want to do:
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”.
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).
The Items of this Array are previously declared in the Files as Strings like this
@property (nonatomic, readwrite) NSInteger sliceID;
@property (nonatomic, retain) NSString *image;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *text;
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.
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.
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.
Hope you understand my bad English. 😉
So, now you’ve declared the property, but you haven’t implemented it. A property declaration, among other things, declares that you will implement one or two accessor methods for the property. So, it’s not (yet) enough just to declare the property; you must also implement the accessor methods that make that property real at run time.
The easiest way to fix this is to synthesize the accessors for the
slicesproperty. If you need some custom behavior, you can implement them yourself, but it doesn’t sound like it—synthesizing is not only easiest, but probably the right solution.See the documentation on properties for more information.