Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Save the other Object in array using for loop

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 818
    Comment on it

    To add the object in array in for Loop we have several methods: first we can have to simply add those objects to the array then we can add them using for loop in array..... **IN example:** we have a simple object *object that we added 3 times at diffrent index postion in array(**mutArray)..** And other method is to add the object from another array: for that we accessed the each object at current index from the array and added that to the another array(**myMutableArray**)...

    NSMutableArray *mutArray=[[NSMutableArray alloc]init];
    
        for(int i=0;i<=2;i++)
        {
            NSString *object=@"Hello";
            [mutArray addObject:object];
        }
         NSLog(@"Mutable Array==%@",mutArray);
    
    
        //if the object are in other array then
    
        NSArray *objArray=[[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",nil];
        NSLog(@"obje==%@",objArray);
        NSMutableArray *myMutableArray=[[NSMutableArray alloc]init];;
    
        for(int index=0;index<objArray.count;index++)
        {
    
            [myMutableArray addObject:[objArray objectAtIndex:index]];
    
    
        }
        NSLog(@"myMutable Array==%@",myMutableArray);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: