我正在尝试将一些数据传递回我的 UIView,它有点复杂,我将尝试解释它。
我有我的
mainViewController // request is made to RequestClass
requestClass // Request is sent off to DB for data, data is returned then passed to seriesDataClass
seriesDataClass // sorts the data and then sends back the needed info to mainViewController using protocol & delegates
这就是我的代码设置协议和委托的样子
主视图控制器.h
#import "SeriesDataClass.h"
@interface MatchingSeriesViewController : UIViewController <GetSeriesViewParsedData>
{
主视图控制器.m
#import "SeriesDataClass.h"
// this is where I set up my protocols delegate.
- (void)viewDidLoad
{
//..
// get delegate ready
SeriesDataClass *seriesDataClass = [[SeriesDataClass alloc] init];
[seriesDataClass setDelegate:self];
//..
// pass data over to requestClass so you can get the info from the DB
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//..
[requestClass GetSeries:requestID];
//..
}
请求类.m
// dose a bunch of stuff then calls seriesDataClass and passes all of its information over to it
//..
SeriesDataClass *seriesDataClass = [[SeriesDataClass alloc] init];
[seriesDataClass recivedData:uncompressedData];
//..
seriesDataClass.h
#import <Foundation/Foundation.h>
// This passes data back to the mainViewController
@protocol GetSeriesViewParsedData <NSObject>
- (void)sendGetSeriesArrays:(NSDictionary *)series LSeries:(NSDictionary *)lSeries;
@end
@interface SeriesDataClass : NSObject <NSXMLParserDelegate> {
//..
}
@property (assign, nonatomic) id <GetSeriesViewParsedData> delegate;
系列数据类.m
@implementation SeriesDataClass
@synthesize delegate;
// then in a method later on i call the delegate to pass the information back to mainViewController but this dosnt do anything atm.
//..
[self.delegate sendGetSeriesArrays:seriesDictionary LSeries:lSeriesDictionary];
//..
主视图控制器.m
// then back in the mainViewController class I Have the method
- (void)sendGetSeriesArrays:(NSDictionary *)series LSeries:(NSDictionary *)lSeries {
// this method is never accessed
}
所以我的问题是我在这个协议/委托的设置中缺少什么,因为它不能正常工作?
我希望问题的结构是有意义的,如果您需要更多信息,请告诉我。