0

I have a class like this.

@interface PathArray : NSObject
@property (nonatomic) CGPoint start;
@property (nonatomic) CGPoint end;
@property (nonatomic) UIColor* color;
@property (nonatomic) CGFloat pathWidth;
- (instancetype) initWithStartPoint: (CGPoint)start andEnd: (CGPoint)end andColor: (UIColor *) color andPathWidth: (CGFloat) pathWidth;
@end

And I have 2 array

NSMutableArray *pathArray;
NSMutableArray<PathArray*> *tempPathArray;

So the question is: How I can get the element from tempPathArray in a loop like this:

for ( int i=0; i<pathArray.count; i++ ) {
        for( int j=0; j<tempPathArray.count; j++ ) {
            pathArray[i].tempPathArray[j]???
        }
    }

Thanks for your help!

  • Your `tempPathArray` is not inside `pathArray`, what are you trying to do? Array inside another array mean you have an array inside `PathArray` object or multiple instance of whatever array you having – Tj3n Mar 26 '18 at 03:33
  • And sorry but I add tempPathArray into pathArray in other loop. [pathArray addObject:tempPathArray]; – Kiet Nguyen Mar 26 '18 at 03:36
  • I think you are doing wrong, you shouldn't make `tempPathArray ` a property – Tj3n Mar 26 '18 at 03:43
  • Check this example: https://stackoverflow.com/questions/37750446/ios-json-parsing-array-with-multiple-array – Mukesh Mar 26 '18 at 08:05
  • Thank you so much! – Kiet Nguyen Mar 26 '18 at 09:22

0 Answers0