objective c - no visible @interface for NSMutable Array declares selector 'addStock' -


i cannot figure out why addstock method not working nsmutablearray object "giuport" . have connected class files. how make interface visible / correct error comes each of times try using addstock method?

the following snippet main.m file rendering error is:

    nsmutablearray *giuport = [[nsmutablearray alloc]init];     [giuport addstock:apple];     [giuport addstock:lvs];     [giuport addstock:verizon]; 

the class .h file in declare nsmutablearray, etc:

@interface bnrportfolio : nsobject  {     nsmutablearray *_stocks; }  @property (nonatomic, copy) nsarray *stocks; @property (nonatomic) float valueofport;  //instance methods -(void)addstock:(bnrstockholding *)s; -(float)valueofport;   @end 

the class .m file in implement nsmutablearray, etc:

@implementation bnrportfolio // array set stuff -(void)setstocks:(nsarray *)s {     _stocks = [s mutablecopy]; }  -(nsarray *)stocks {     return [_stocks copy]; }  // instance methods -(void)addstock:(bnrstockholding *)s    {     // check see if array exists     if (!_stocks) {         _stocks = [[nsmutablearray alloc]init];     }     [_stocks addobject:s]; }  -(float)valueofport  {     //take sum of stocks in port     float sum = 0;     (bnrstockholding *s in _stocks) {         sum += [s valueindollars];      }     return sum; }  @end 

the -addstock: method method of bnrportfolio class. attempting call on instance of nsmutablearray. there's no such method on nsmutablearray, compiler complaining about.

apparently, want allocate , initialize instance of bnrportfolio , call -addstock: on that.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -