-1

I am using UISplitViewController and I have a Master Controller and Detail Controller.

The Master Controller I have a NSMutableArray defined like so:

#import "MasterController.h"
#import "DetailController.h"

@interface MasterController ()

@property NSMutableArray *objects;
@end

@implementation MasterController

and I am trying to call it in my Detail Controller like so:

#import "DetailController.h"
#import "MasterController.h"

@interface DetailController ()
{
     MasterController *purchaseOrder;
}

@end

@implementation DetailController

- (void)GetRequest
{

    NSArray *tableData = [dataSource.areaData GetPurchaseOrderItems:[NSString stringWithFormat:@"%@%@",areaPickerSelectionString,unitPickerSelectionString]];
    NSLog(@"%@", tableData);
    //TODO: foreach tableData populate object.
    [purchaseOrder object];

}

ultimately I am looking to populate the object with each item in tableData. But when I call object, I get this error:

No visible @interface for 'LHPurchaseOrderMaster' declares the selector 'object'

how would I accomplish what I am trying to accomplish ?

jww
  • 97,681
  • 90
  • 411
  • 885
user979331
  • 11,039
  • 73
  • 223
  • 418
  • Possible duplicate of [Objective-C Singleton Objects and Global Variables](http://stackoverflow.com/questions/5448476/objective-c-singleton-objects-and-global-variables) and [Global variable NSMuteableArray using Singleton Class](http://stackoverflow.com/q/5795997/608639) – jww Apr 29 '15 at 20:46
  • I dont understand how these will help – user979331 Apr 29 '15 at 20:50
  • this is not a duplicate – user979331 Apr 29 '15 at 20:50

1 Answers1

1

So many things amiss here. A few short pointers to hopefully help:

You've put @property NSMutableArray *objects; in your private interface. Try moving this to the header file and making it public. Any reason why you haven't declared this as @property (nonatomic, strong) NSMutableArray *objects; ?

The syntax [someInstance someMethod] means that your purchaseOrder instance of MasterController is trying to call a method called object of which you've not provided us any details about. Perhaps you're trying to call objects instead. But this will only work if you make it public as noted above.

If you're attempting to design a better API than that, you can keep your NSMutableArray of objects private, and provide a public NSArray of maybe *allObjects and inside yourDetailController a getter method like

- (NSArray*)allObjects {
    return [self.objects copy];
}

You've not provided any information about LHPurchaseOrderMaster, but hopefully I'm on the right track with helping you solve your problem here.

Frankie
  • 11,508
  • 5
  • 53
  • 60