removeHoldings () will come to an error like:
No visible @interface for ‘NSArray’ declares the selector ‘removeObjectAtIndex:’
anyone who can slove this will be nice for me.
here is me code:
DXJPortfolio.h
#import <Foundation/Foundation.h>
#import "DXJStockHolding.h"
//@class DXJStockHolding;
NS_ASSUME_NONNULL_BEGIN
@interface DXJPortfolio :NSObject
@property(nonatomic,copy)NSArray *holdings;
-(float)totalValue;
-(float)totalCost;
-(void)addHoldings:(DXJStockHolding *)dxj;
-(void)removeHlodings:(unsigned int)i;
-(void)addforeignHoldings:(DXJStockHolding *)fdxj;
@end
DXJPortfolio.m
#import "DXJPortfolio.h"
//#import "DXJStockHolding.h"
@interface DXJPortfolio ()
{
    NSMutableArray *_holidings;
}
@end
@implementation DXJPortfolio
    
-(void)setHoldings:(NSArray *)h{
    _holdings = [h mutableCopy];
}
-(NSArray *)holding{
    return [_holdings mutableCopy];
}
-(void)addHoldings:(DXJStockHolding *)dxj{
    
    if(!_holdings){
        _holdings  = [[NSMutableArray alloc]init];
    }
    [_holidings addObject:dxj];
}
-(void)addforeignHoldings:(DXJStockHolding *)fdxj{
    if(!_holidings){
        _holdings = [[NSMutableArray alloc]init];
        
    }
    [_holidings addObject:fdxj];
}
-(void)removeHlodings:(unsigned int)i{
    if(i < _holdings.count){
        [_holdings removeObjectAtIndex:i];
    }else{
        NSLog(@"error");
    }
}
- (float)totalValue
{
    // Sum up total value of the StockHoldings
    float sum = 0;
    for (DXJStockHolding *h in _holdings) {
        sum += [h valueInDollars];
    }
    return sum;
}
- (float)totalCost
{
    // Sum up total cost of the StockHoldings
    float sum = 0;
    for (DXJStockHolding *h in _holdings) {
        sum += [h costInDollars];
    }
    return sum;
}
@end