如何将Parse查询发送到另一个ViewController

时间:2015-04-14 18:10:01

标签: ios parse-platform

我正在尝试通过查询salesArray = [[NSMutableArray alloc] initWithArray:objects]发送到EditData,我无法为我的生活弄清楚。我正在尝试填充选择器视图..我使用[parseConnection parseProduct]执行查询,但无法将数组转到EditData.m

ParseConnection.h

#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
#import "Constants.h"
//#import "EditData.h"

@protocol ParseConnectionDelegate <NSObject>

@end

@interface ParseConnection : NSObject //<PFSubclassing>
{
  NSMutableArray *salesArray, *callbackArray, *contractorArray, *rateArray, *zipArray, *jobArray;    
}

- (void)parseSalesman;

@property (strong, nonatomic) id<ParseConnectionDelegate> delegate; //added

@property (strong, nonatomic) UITextField *salesName;

ParseConnection.m

    #import "ParseConnection.h"

    @interface ParseConnection ()
    {
      //  NSMutableArray *salesArray, *callbackArray, *contractorArray, *rateArray, *zipArray, *jobArray;
    }
    @end

    @implementation ParseConnection

    #pragma mark - EditData PickerView
    - (void)parseSalesman {
        PFQuery *query = [PFQuery queryWithClassName:@"Salesman"];
        query.cachePolicy = kPFCACHEPOLICY;
        [query selectKeys:@[@"SalesNo"]];
        [query selectKeys:@[@"Salesman"]];
        [query orderByDescending:@"SalesNo"];
        [query whereKey:@"Active" containsString:@"Active"];
        [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
            salesArray = [[NSMutableArray alloc]initWithArray:objects];
             // NSLog(@"adStr is %@",salesArray);
        }];
    }

EditData.m

#import "EditData.h"

@interface EditData ()
{
    NSMutableArray *salesArray, *callbackArray, *contractorArray, *rateArray;
}
@property (nonatomic, weak) UIStepper *defaultStepper;
@end

@implementation EditData
@synthesize custNo, leadNo, active, date, first, last, company, address, city, state, zip, phone, aptDate, email, amount, spouse, callback, saleNo, jobNo, adNo, photo, comment, rate, start, complete;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;  //fix
    self.listTableView.dataSource = self;
    self.listTableView.delegate = self;
    self.listTableView.rowHeight = UITableViewAutomaticDimension;
    self.listTableView.estimatedRowHeight = ROW_HEIGHT;
    self.listTableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0);
 // self.listTableView.tableHeaderView = view; //makes header move with tablecell


     ParseConnection *parseConnection = [[ParseConnection alloc]init];
    [parseConnection parseProduct];
      NSLog(@"adStr is %@",self.adName.text);

}

1 个答案:

答案 0 :(得分:0)

而不是在salesArray内创建ParseConnection,而是传递EditData内的salesArray。然后,在完成块中,向其添加对象,而不是初始化它。

在将EditData作为参数传递给parse...方法之前,不要忘记在{{1}}中初始化{{1}}。